<
8000
div class="d-flex flex-column flex-md-row flex-items-start flex-md-items-center">
Accessing dunders via type object produces TypeVar clashes #14814
Labels
bug
mypy got something wrong
Uh oh!
There was an error while loading. Please reload this page.
Consider the following code:
mypy happily accepts
anext_via_instance
, but inanext_via_type
it fails with:If I add a
reveal_type(anext)
inanext_via_type
:This behavior doesn't seem to be a recent change; it showed up on every version I spot-checked on the playground, and is still present on master. From the error message it looks like some kind of issue with TypeVar inference, but I'm not an expert.
(I'm trying to write something like
anext_via_type
in order to mimic the interpreter's behavior accessing a magic method in a specific circumstance; it won't accept an instance attribute, only a class attribute, so I don't want to accept an instance attribute either.)The text was updated successfully, but these errors were encountered: