mypy无法识别属性:无法确定“ s”的类型

时间:2020-01-30 19:19:30

标签: python python-3.x mypy python-attrs

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

1 个答案:

答案 0 :(得分:1)

嘿,这很奇怪,也许是mypy中的错误!将uuid.UUID(id)重命名为其他名称,它将起作用:

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