Search code examples
pythonpython-3.xmypypython-attrs

mypy does not recognize attrs: Cannot determine type of '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)

Do I need to install something else for attrs support?


Solution

  • Heh this is odd and maybe a bug in mypy! Rename types.py into something else and it will work:

    $ 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
    

    Computers! ¯\_(ツ)_/¯