Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Remove _field_types from abstract classes: this is not a feature. Per @terryjreedy See https://github.com/python/cpython/issues/135797#issuecomment-2993817570 #14320

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

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

Conversation

hunterhogan
Copy link
Contributor

No description provided.

Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

Comment on lines +47 to +49
if sys.version_info >= (3, 13):
_field_types: ClassVar[dict[str, Any]]

Copy link
Member

@brianschubert brianschubert Jun 22, 2025

Choose a reason for hiding this comment

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

Instead of repeating this in every concrete class, it might make sense to move this to a protocol that these classes all inherit from. Something like

@type_check_only
class _ConcreteNode(Protocol):
    if sys.version_info >= (3, 13):
        _field_types: ClassVar[dict[str, Any]]

That would reduce the chance of something getting out of sync if anything changes about _field_types in the future

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree 1 billion percent with not duplicating the code. I don't know how to do it, however. If I were to try to edit the file, I would give your code snippet to AI assistants and ask them to explain to me how to incorporate it. 🫤

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