1
> 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支持吗?

4

1 回答 1

1

嘿,这很奇怪,可能是 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

电脑!¯\_(ツ)_/¯

于 2020-02-01T05:40:35.077 回答