-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
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
Allow subclassing Any at runtime #91154
Comments
Discussed on typing-sig at https://mail.python.org/archives/list/[email protected]/thread/GULRKYI7XOB3FLAEFC6OYSTBS5FIA5PU/ |
Thanks for the idea and patch! |
I understand the rationale for this change, but it does complicate the type system in unspecified (and not fully understood ways). For example
I know it is too late to revert this in 3.11, but is there a chance we could revisit the decision to make |
We can always decide to change our mind and deprecate this feature, but that's putting the cart before the horse. Type checkers must support Any as a base class (it will come up if you inherit from a class in an untyped library), so the concept needs to be part of the type system somehow. Formalizing what subclassing Any means could be useful, but existing type checkers manage without it. |
Is there a better forum to continue this discussion? I'm not sure I understand why inheriting from |
@superbobry I'm a little confused here, because this was a change to runtime behaviour, but your concern seems to be with whether type checkers should allow Nonetheless, if you do want to argue that we should standardise the behaviour of type checkers so that they always disallow subclassing |
Thanks for chiming in @AlexWaygood! My concern is that this change does not just affect the runtime behavior as type checkers will now observe I will follow up on typing-sig@. |
I just discovered this behavior change recently, when our codebase upgraded to python 3.11. I would have expected But also, an object can get the same behavior of inheriting from |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: