-
-
Notifications
You must be signed in to change notification settings - Fork 2.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
__subclasses__() -> "Only concrete class can be given where "Type[C]" is expected" #6199
Comments
under what circumstance would this also still doesn't explain why adding an annotation causes it to be ok (which is why I created a separate issue from those two) |
Although in your code
It does. Because with your annotation |
isn't the place where I added the annotation also an assignment from |
No, that check was added only as an additional special-case check when the types appear as "top level" in an assignment or function call, it doesn't affect subtyping, so doesn't trigger when the types appear in a nested position. This whole abstract Also please stop arguing, it is not helpful. |
I'm not arguing, simply curious -- thanks for the explanation that's all I wanted here <3 |
@asottile OK, sorry, sometimes it is hard to get the tone from written text :-) |
this seems related to #5374 but only in the error message (?)
I'm trying to port a section of code that was previously using a metaclass to just using
__subclasses__
. Here's a minimal example of what I'm trying to do:This, as written, fails with:
If I replace the assignment of
subclasses
with the commented out line, it succeeds:Type[C]
objects in a typesafe manner even without theinspect.isabstract
call (notice I'm never even attempting to construct aType[C]
)The text was updated successfully, but these errors were encountered: