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

[Future] Python 3.13 conformance #387

Closed
JelleZijlstra opened this issue May 25, 2024 · 5 comments
Closed

[Future] Python 3.13 conformance #387

JelleZijlstra opened this issue May 25, 2024 · 5 comments

Comments

@JelleZijlstra
Copy link

Several tests fail when I run pytest in the beartype repo on Python 3.13 beta 1, which was recently released. (For context, the final release of Python 3.13 is due in October.)

  • FAILED beartype_test/a00_unit/a00_core/test_a90_typing.py::test_api_typing - AssertionError: assert {'AsyncContex...'is_protocol'} == set()
    • beartype is missing various names that were recently added to the typing module
  • FAILED beartype_test/a00_unit/a10_data/hint/pep/sign/test_datapepsignset.py::test_hint_signs_origin_isinstanceable_args - AssertionError: "typing.ContextManager" accepts 2 arguments, but expected to accept 1 arguments.
    • This class now takes a second, optional type parameter (see PEP 696).
  • FAILED beartype_test/a00_unit/a60_check/a90_door/test_checkdoor.py::test_door_typehint_die_if_unbearable - beartype.roar.BeartypeDoorException: <class 'beartype.door._cls.doorsub._TypeHintOriginIsinstanceableArgs1'> type must have 1 argument(s), but got 2.
    • Related to same ContextManager change
  • FAILED beartype_test/a00_unit/a60_check/a90_door/test_checkdoor.py::test_door_typehint_is_bearable - beartype.roar.BeartypeDoorException: <class 'beartype.door._cls.doorsub._TypeHintOriginIsinstanceableArgs1'> type must have 1 argument(s), but got 2.
    • Probably the same too
  • FAILED beartype_test/a00_unit/a70_decor/a40_code/a90_pep/test_decorpep673.py::test_decor_pep673 - TypeError: update() argument must be dict or another FrameLocalsProxy
    • I think there was some change in how frame locals were handled, may need to cast to a dict
  • FAILED beartype_test/a00_unit/a70_decor/test_decortype.py::test_decor_type_descriptor_builtin - AssertionError: assert False
    • Docstrings now strip leading whitespace in the AST.
  • FAILED beartype_test/a90_func/pep/test_pep561_static.py::test_pep561_pyright - subprocess.CalledProcessError: Command '('pyright', '--pythonversion', '3.13', 'beartype')' returned non-zero exit status 1.
    • Not sure why this is different.
@leycec
Copy link
Member

leycec commented May 25, 2024

Wonderful! Thanks so much both for the rapid heads-up and your one-line resolutions. Ordinarily, I'd play Japanese video games instead of doing anything until October – at which point CPython 3.13 would release, everything in @beartype would break, users would loudly protest while rioting on our issue tracker, and Microsoft would raise its giant fist in wrathful vengeance. You'd think I'd learn.

However, I note this is related to a draft implementation of PEP 649 – which you're diligently spear-heading. Wonderful! Simply wonderful. PEP 649 is the glorious future the runtime community has been half-heartedly waiting for all these years.

In This Case...

Allow me to actually do something. I'll immediately re-prioritize Python 3.13 conformance for our upcoming @beartype 0.19.0 release – slated for release in a week or so. My immediate immediate priority is issue #382, because it turns out @beartype and multiprocessing play poorly due to exception pickling weirdness. ...i am vomiting

Directly after, I'll happily tackle this. Should take a day or so. Maybe? Everything looks trivial, thankfully – just a bit tedious, which is usually the case on CPython bumps.

Thanks again! And thanks for tackling PEP 649 head-on. Lotsa fun stuff happening. Emoji cat smiles contentedly. 😸

@leycec leycec changed the title Tests fail on Python 3.13 [Future] Python 3.13 conformance May 25, 2024
leycec added a commit that referenced this issue May 31, 2024
This commit is the next in a commit chain officially supporting the
upcoming release of Python 3.13, en-route to resolving future issue #387
kindly submitted by core Python `typing` mega-boss @JelleZijlstra (Jelle
Zijlstra). Specifically, this commit generalizes internal introspection
of standard type hint factories to note that the following factories now
conditionally accept a second optional child type hint under Python ≥
3.13, due to PEP 696 (i.e., "Type Defaults for Type Parameters"):

* `contextlib.AsyncContextManager[...]`.
* `contextlib.ContextManager[...]`.
* `typing.AsyncContextManager[...]`.
* `typing.ContextManager[...]`.

Let's do this, `typing` bois! (*Final vanquishment of a languishing vanguard!*)
@leycec
Copy link
Member

leycec commented May 31, 2024


it's. beginning.

leycec added a commit that referenced this issue Jun 1, 2024
This commit is the next in a commit chain officially supporting the
upcoming release of Python 3.13, en-route to resolving future issue #387
kindly submitted by core Python `typing` mega-boss @JelleZijlstra (Jelle
Zijlstra). Specifically, this commit resolves *all* remaining
compatibility issues with respect to Python 3.13 – except for static
type-checking under `mypy` and `pyright`, which remains an open (but
largely boring) question. For all intents and purposes, @beartype now
officially supports Python 3.13! *Wohoooo.* (*Fully syntactic synapses snap sinfully!*)
@leycec
Copy link
Member

leycec commented Jun 1, 2024

Effectively resolved by c8c4f05. All tests now pass under Python 3.13.0 beta 1 – except possibly static type-checking integration tests with mypy and pyright, which remain an open (but largely boring) question. Technically, mypy and pyright both pass on my machine without modification. Pragmatically, that kinda confuses me; I expected catastrophic explosions there but didn't get them. Maybe everything's already been fixed? No idea. I'll delve into this a bit deeper tomorrow when my brain has slept and close this out properly.

For all intents and purposes, @beartype now officially supports Python 3.13. The @beartype HEAD should now be ready for PEP 649 and your gentle ministrations.

Oh, And...

...thanks so much for those one-line solutions! They truly were a tremendous help. Unsurprisingly, you were right about everything. I just did everything you said. This is a teaching moment. Would you mind if I ping you for similar advice next year when the inevitable Python 3.14.0 beta drops? please say yes please say yes 🙏

@JelleZijlstra
Copy link
Author

Thank you! Yes, happy to help with future changes needed for conformance with 3.14.

@leycec
Copy link
Member

leycec commented Jun 4, 2024

Excellent. That's wonderful. You are the wise CPython sage. I'll humbly defer to your wisdom in a year... if I even remember having this discussion in a year. Unreadable post-it note on my monitor, don't fail me now! </gulp>

Oh – and I've confirmed happiness from the latest stable releases of both mypy and pyright. Let's quietly close this out. Thanks again for being so super! I bow towards you. 🙇

@leycec leycec closed this as completed Jun 4, 2024
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

No branches or pull requests

2 participants