mypy无法识别属性:无法确定's'类型


> pip3.8 list
Package           Version
----------------- -------
attrs             19.3.0
mypy              0.761
mypy-extensions   0.4.3
pip               19.3.1
setuptools        42.0.2
typed-ast         1.4.1
typing-extensions 3.7.4.1
wheel             0.33.6
> mypy --version
mypy 0.761
# types.py
import typing
import attr
@attr.s(auto_attribs=True, slots=True, frozen=True)
class Test:
b: bool = False
> mypy types.py
types.py:4: error: Cannot determine type of 's'
Found 1 error in 1 file (checked 1 source file)

我是否需要安装其他东西才能获得attrs支持?

呵呵,这很奇怪,也许是mypy中的一个错误!将types.py重命名为其他名称,它将起作用:

$ mypy types.py
types.py:4: error: Cannot determine type of 's'
Found 1 error in 1 file (checked 1 source file)
$ mv types.py t.py
$ mypy t.py
Success: no issues found in 1 source file

计算机!¯_(ツ)_/¯

最新更新