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

Experiment: decouple types.DynamicClassAttribute from property #12762

Closed
wants to merge 2 commits into from

Conversation

tungol
Copy link
Contributor

@tungol tungol commented Oct 9, 2024

I'm curious to see what the tests look like.

I'm curious to see what the tests look like.
@tungol tungol marked this pull request as draft October 9, 2024 23:41

This comment has been minimized.

@tungol
Copy link
Contributor Author

tungol commented Oct 10, 2024

Less breakage than I imagined. "Run mypy against the stubs" passes for 3.11+, which I suspect means that enum.property being named property is sufficient to get (some of) the special treatment, but the primer results show it's not all of it. One other thing I want to try.

Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

ignite (https://github.com/pytorch/ignite)
+ ignite/engine/events.py:206: error: Definition of "name" in base class "CallableEventWithFilter" is incompatible with definition in base class "Enum"  [misc]

nox (https://github.com/wntrblm/nox)
+ nox/sessions.py:1106: error: Returning Any from function declared to return "str"  [no-any-return]

@tungol
Copy link
Contributor Author

tungol commented Oct 10, 2024

Subclassing doesn't appear to make any difference.

@tungol tungol closed this Oct 10, 2024
@AlexWaygood
Copy link
Member

"Run mypy against the stubs" passes for 3.11+, which I suspect means that enum.property being named property is sufficient to get (some of) the special treatment,

It's actually because mypy hardcodes in some extra special casing to cope with typeshed's stubs here. See python/mypy#14133

@tungol tungol deleted the DynamicClassAttribute branch October 10, 2024 08:20
@tungol
Copy link
Contributor Author

tungol commented Oct 10, 2024

Thanks for the context, I appreciate 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