-
-
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
type[A] cannot be instantiated via partial if A is abstract #17556
Labels
bug
mypy got something wrong
Comments
Could that be related?
Then
|
@hauntsaninja thank you |
JukkaL
pushed a commit
that referenced
this issue
Oct 9, 2024
JukkaL
pushed a commit
that referenced
this issue
Oct 9, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For a variable
cls
annotated ascls: type[A]
whereA
is an ABC, the semantics from #2853 suggest that mypy resolves the type of the variable to concrete subclasses of A. The semantics do not seem to apply if the referenced concrete subclass is not instantiated directly viacls()
, but rather via apartial
as inpartial(cls, *args, **kwargs)()
.Mypy complains with
cannot instantiate abstract class
errors if a class variable referencing a presumed-concrete subclass of an ABC is invoked viapartial
:To Reproduce
Expected Behavior
I'd have expected this to work, since if
cls
in the above example refers to a concrete subclass per #2853, it should be legal to usepartial
on it.Instead, we get
Your Environment
mypy.ini
(and other config files):The text was updated successfully, but these errors were encountered: