-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
bpo-46998: Allow subclassing Any at runtime #31841
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
Changes from 1 commit
bc71456
abea39a
771f492
900f2c7
6e76441
b00ab17
4d913ad
1c1ab38
4927e78
68ea3a8
f94b7e0
05db029
e11f405
63b00e4
ac7b4a8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -430,7 +430,7 @@ def __getitem__(self, parameters): | |
|
||
class _AnyMeta(type): | ||
def __instancecheck__(self, obj): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we even have this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm fine with removing it (as this PR currently does for My reasoning for keeping it is that |
||
raise TypeError("Any cannot be used with isinstance()") | ||
raise TypeError("typing.Any cannot be used with isinstance()") | ||
|
||
def __repr__(self): | ||
|
||
return "typing.Any" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The metaclass is unfortunate because it restricts what classes can double-inherit from Any (due to metaclass conflicts). Seems unavoidable though.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not entirely unavoidable, if we were willing to give up on instancecheck (and repr), I'd say we could just remove the metaclass entirely