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
runs without a problem, but gives error in pyright and mypy. Pyright complains
⮞ mypy ./test.py
test.py:9: error: Dataclass attribute may only be overridden by another attribute [misc]
test.py:13: error: Missing positional argument "x" in call to "B" [call-arg]
Found 2 errors in 1 file (checked 1 source file)
and mypy complains
⮞ pyright ./qwq.py
/path/to/test.py
/path/to/test.py:10:9 - error: "x" overrides symbol of same name in class "A"
"property" is not assignable to "int" (reportIncompatibleVariableOverride)
/path/to/test.py:13:5 - error: Argument missing for parameter "x" (reportCallIssue)
2 errors, 0 warnings, 0 informations
My pylance in vscode somehow only reports the second error ("x" missing) but not the first (property cannot override int).
I believe that AbstractVar property is an intentional feature, as the doc says
An AbstractVar[T] must be overridden by an attribute annotated with AbstractVar[T], AbstractClassVar[T], ClassVar[T], T, or a property returning T.
I suggest this to be fixed by _ModuleMeta adding something (to its __new__?) at typechecking time to modify the __annotations__ of its initializer.
The text was updated successfully, but these errors were encountered:
Yup, implementing an AbstractVar with a property is an intentional feature.
That said, I don't know of a way to make this static-type-checking compatible. If you think you have a way to do that then I'd be happy to see a PR doing so!
The following code:
runs without a problem, but gives error in pyright and mypy. Pyright complains
and mypy complains
My pylance in vscode somehow only reports the second error ("x" missing) but not the first (property cannot override int).
I believe that
AbstractVar property
is an intentional feature, as the doc saysI suggest this to be fixed by
_ModuleMeta
adding something (to its__new__
?) at typechecking time to modify the__annotations__
of its initializer.The text was updated successfully, but these errors were encountered: