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

Ignore PEP 649 + 695 implementation details in stubtest #18469

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cdce8p
Copy link
Collaborator

@cdce8p cdce8p commented Jan 15, 2025

PEP 649 added __annotate__ and PEP 695 __classdictcell__. At the moment it looks like 649 will be enabled with 3.14 at which point stubtest would complain about these. It probably makes sense to add them to the ignore list now.

mypy/stubtest.py Outdated
@@ -1486,6 +1486,9 @@ def verify_typealias(
"__instancecheck__",
"__subclasshook__",
"__subclasscheck__",
# PEP 695 implementation details
"__annotate__",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__annotate__ is from PEP 649, not 695. __classdictcell__ does come from PEP 695 (so it's already in 3.12+), but is used only during class body execution and I don't think stubtest should see it. Did you encounter problems with it?

Copy link
Collaborator Author

@cdce8p cdce8p Jan 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__annotate__ is from PEP 649, not 695. __classdictcell__ does come from PEP 695 (so it's already in 3.12+), but is used only during class body execution and I don't think stubtest should see it.

Seems I mixed them up again. Sorry about that.

Did you encounter problems with it?

I did ran the test suite with Python 3.14.0a4 yesterday. These were two of the test failures. IIRC they had been there since some time, maybe 3.14.0a1?

___________________________________________________ StubtestUnit.test_named_tuple ___________________________________________________
...
E           AssertionError: error: test_module.X1.__annotate__ is not present in stub
E             Stub: in file test_module.pyi
E             MISSING
E             Runtime: in file /.../cpython/Lib/typing.py:2982
E             def (format)
E             
E             error: test_module.X1.__classdictcell__ is not present in stub
E             Stub: in file test_module.pyi
E             MISSING
E             Runtime:
E             <cell at 0x108763ee0: dict object at 0x1088a70c0>
E             
E             error: test_module.X2.__annotate__ is not present in stub
E             Stub: in file test_module.pyi
E             MISSING
E             Runtime: in file /.../cpython/Lib/typing.py:2982
E             def (format)
E             
E             error: test_module.X2.__classdictcell__ is not present in stub
E             Stub: in file test_module.pyi
E             MISSING
E             Runtime:
E             <cell at 0x108763490: dict object at 0x1088a6140>
E             
E             ...
E           assert {'test_module...e.X2.__new__'} == {'test_module.X2.__new__'}
E             
E             Extra items in the left set:
E             'test_module.X1.__classdictcell__'
E             'test_module.X2.__classdictcell__'
E             'test_module.X1.__annotate__'
E             'test_module.X2.__annotate__'
E             Use -v to get more diff

mypy/test/teststubtest.py:233: AssertionError
_____________________________________________ StubtestUnit.test_runtime_typing_objects ______________________________________________
...
E           AssertionError: error: test_module.X.__annotate__ is not present in stub
E             Stub: in file test_module.pyi
E             MISSING
E             Runtime: in file test_module.py:3
E             def (format, /)
E             
E             Found 1 error (checked 1 module)
E             
E           assert {'test_module.X.__annotate__'} == set()
E             
E             Extra items in the left set:
E             'test_module.X.__annotate__'
E             Use -v to get more diff

mypy/test/teststubtest.py:233: AssertionError
====================================================== short test summary info ======================================================
FAILED mypy/test/teststubtest.py::StubtestUnit::test_named_tuple - AssertionError: error: test_module.X1.__annotate__ is not present in stub
FAILED mypy/test/teststubtest.py::StubtestUnit::test_runtime_typing_objects - AssertionError: error: test_module.X.__annotate__ is not present in stub

@cdce8p cdce8p force-pushed the stubtest-ignore-695-attributes branch from 74647a8 to c8c9901 Compare January 15, 2025 08:22
@cdce8p cdce8p changed the title Ignore PEP 695 implementation details in stubtest Ignore PEP 649 + 695 implementation details in stubtest Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants