Bug Report
Annotating __new__(...) -> typing.NoReturn or __init__(...) -> typing.NoReturn causes false positives when accessing @classmethods and typing.ClassVar-annotated attributes.
To Reproduce
from typing import NoReturn , Any , ClassVar
class A :
attr : ClassVar [str ] = ""
def __init__ (cls , * args : Any , ** kwargs : Any ) -> NoReturn :
raise RuntimeError
@classmethod
def f (cls ) -> None :
pass
class B :
attr : ClassVar [str ] = ""
@classmethod
def f (cls ) -> None :
pass
Expected Behavior
No issues on any of the following:
A .f ()
A .attr
B .f ()
B .attr
Actual Behavior
A .f () # mypy: "Callable[[VarArg(Any), KwArg(Any)], NoReturn]" has no attribute "f" [attr-defined]
A .attr # mypy: "Callable[[VarArg(Any), KwArg(Any)], NoReturn]" has no attribute "attr" [attr-defined]
B .f ()
B .attr
Your Environment
Mypy version used: 0.990 and master branch of https://mypy-play.net/
Mypy command-line flags: None
Mypy configuration options from mypy.ini (and other config files): None
Python version used: 3.10
👍 React with 👍 2fofoni and lkct