Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vendor typing._allowed_types removed in Python 3.14 #646

Merged
merged 2 commits into from
Nov 30, 2024

Conversation

hugovk
Copy link

@hugovk hugovk commented Nov 3, 2024

Fix for Python 3.14 alpha, which removed the private/internal (underscored) typing._allowed_types: python/cpython#124090

Before:

❯ python3.14 -m pip install ghapi -q
❯ python3.14 -c "from ghapi.all import GhApi; print(GhApi)"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
    from ghapi.all import GhApi
  File "/Library/Frameworks/Python.framework/Versions/3.14/lib/python3.14/site-packages/ghapi/all.py", line 1, in <module>
    from .core import *
  File "/Library/Frameworks/Python.framework/Versions/3.14/lib/python3.14/site-packages/ghapi/core.py", line 9, in <module>
    from fastcore.all import *
  File "/private/tmp/fastcore/fastcore/all.py", line 3, in <module>
    from .dispatch import *
  File "/private/tmp/fastcore/fastcore/dispatch.py", line 174, in <module>
    @typedispatch
     ^^^^^^^^^^^^
  File "/private/tmp/fastcore/fastcore/dispatch.py", line 150, in __call__
    self.d[nm].add(f)
    ~~~~~~~~~~~~~~^^^
  File "/private/tmp/fastcore/fastcore/dispatch.py", line 93, in add
    else: a0,a1 = _p2_anno(f)
                  ~~~~~~~~^^^
  File "/private/tmp/fastcore/fastcore/dispatch.py", line 46, in _p2_anno
    hints = type_hints(f)
  File "/private/tmp/fastcore/fastcore/basics.py", line 355, in type_hints
    if not isinstance(f, typing._allowed_types): return {}
                         ^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.14/lib/python3.14/typing.py", line 3829, in __getattr__
    raise AttributeError(f"module {__name__!r} has no attribute {attr!r}")
AttributeError: module 'typing' has no attribute '_allowed_types'

After:

python3.14 -c "from ghapi.all import GhApi; print(GhApi)"
<class 'ghapi.core.GhApi'>

@jph00
Copy link
Contributor

jph00 commented Nov 30, 2024

Many thanks! This is an nbdev project, so the notebooks are the source - can you please update there?

@hugovk
Copy link
Author

hugovk commented Nov 30, 2024

Updated, how does this look?

@jph00
Copy link
Contributor

jph00 commented Nov 30, 2024

Great, thanks!

@jph00 jph00 merged commit c060837 into AnswerDotAI:master Nov 30, 2024
10 of 14 checks passed
@hugovk hugovk deleted the fix-allowed-types branch November 30, 2024 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants