biqqles / dataclassy

A fast and flexible reimplementation of data classes
https://pypi.org/project/dataclassy
Mozilla Public License 2.0
82 stars 9 forks source link

New mypy error with 0.11.0: Cannot instantiate type "Type[<nothing>]" #58

Closed lost-theory closed 3 years ago

lost-theory commented 3 years ago

We ran into this mypy typing error below when upgrading from 0.10.3 to 0.11.0.

Here are the steps to reproduce:

x.py:

import dataclassy

@dataclassy.dataclass(slots=True, kwargs=True, repr=True)
class Foo:
    bar: str = "bar"

if __name__ == "__main__":
    x = Foo()
    print(x.bar)
$ python3 -mvenv ~/env3
$ ~/env3/bin/pip install mypy dataclassy==0.10.3
Collecting mypy
  Using cached mypy-0.910-cp38-cp38-manylinux2010_x86_64.whl (22.8 MB)
Collecting dataclassy==0.10.3
  Using cached dataclassy-0.10.3-py3-none-any.whl (23 kB)
Collecting typing-extensions>=3.7.4
  Using cached typing_extensions-3.10.0.2-py3-none-any.whl (26 kB)
Collecting toml
  Using cached toml-0.10.2-py2.py3-none-any.whl (16 kB)
Collecting mypy-extensions<0.5.0,>=0.4.3
  Using cached mypy_extensions-0.4.3-py2.py3-none-any.whl (4.5 kB)
Installing collected packages: typing-extensions, toml, mypy-extensions, mypy, dataclassy
Successfully installed dataclassy-0.10.3 mypy-0.910 mypy-extensions-0.4.3 toml-0.10.2 typing-extensions-3.10.0.2

$ ~/env3/bin/python x.py
bar
$ ~/env3/bin/mypy x.py
Success: no issues found in 1 source file

$ ~/env3/bin/pip install --upgrade dataclassy==0.11.0
Collecting dataclassy==0.11.0
  Using cached dataclassy-0.11.0-py3-none-any.whl (23 kB)
Installing collected packages: dataclassy
  Attempting uninstall: dataclassy
    Found existing installation: dataclassy 0.10.3
    Uninstalling dataclassy-0.10.3:
      Successfully uninstalled dataclassy-0.10.3
Successfully installed dataclassy-0.11.0
$ ~/env3/bin/python x.py
bar
$ ~/env3/bin/mypy x.py
x.py:4: error: Cannot instantiate type "Type[<nothing>]"
Found 1 error in 1 file (checked 1 source file)
biqqles commented 3 years ago

Mypy strikes again. I need to include it in the CI because I don't use it myself and forget to test. Will try to work out what it doesn't like.

biqqles commented 3 years ago

Fix released in v0.11.1.