You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from .bimportBaseclassCircular:
@propertydefv(self) ->str:
return"value"circular=Circular()
Expected Behavior
self._v to have the correct type for all children. Or at least consistently fail rather than now where somehow the module name matters.
Actual Behavior
c.py:5: error: Cannot determine type of "_v" [has-type]
c.py:5: note: Revealed type is "Any"
a.py:5: note: Revealed type is "builtins.str"
Found 1 error in 1 file (checked 5 source files)
Notice that a.py has the correct type but not c.py.
Your Environment
Mypy version used: mypy 1.15.0 (compiled: yes)
Mypy command-line flags: Nothing
Mypy configuration options from mypy.ini (and other config files): Nothing
Python version used: 3.9.19
Additional notes
Pyright works in this case.
The first character of the file name is important. In this case, since Base is in b.py, any module named after b alphabetically (i.e., c, d, e, etc...) will fail to determine the type but not a.py. E.g., if b.py was instead d.py, then both a.py and c.py will have the correct type.
The bottom imports and the Base import in circular.py are needed to reproduce this. If removed, this works.
Workaround
Explicitly add the type:
self._v: t.Final[str] =vorcircular.v
The text was updated successfully, but these errors were encountered:
To Reproduce
mkdir mypyissue cd mypyissue touch __init__.py a.py b.py c.py circular.py py.typed
a.py
:b.py
:c.py
:circular.py
Expected Behavior
self._v
to have the correct type for all children. Or at least consistently fail rather than now where somehow the module name matters.Actual Behavior
Notice that
a.py
has the correct type but notc.py
.Your Environment
mypy.ini
(and other config files): NothingAdditional notes
Base
is inb.py
, any module named afterb
alphabetically (i.e.,c
,d
,e
, etc...) will fail to determine the type but nota.py
. E.g., ifb.py
was insteadd.py
, then botha.py
andc.py
will have the correct type.Base
import incircular.py
are needed to reproduce this. If removed, this works.Workaround
Explicitly add the type:
The text was updated successfully, but these errors were encountered: