Open altendky opened 4 years ago
I have also experienced this issue when running mypy
on my desert code. Here is an even more minimal example:
import desert
from dataclasses import dataclass
from typing import List
from marshmallow import fields
@dataclass
class Foo:
list_of_strings: List[str] = desert.field(
fields.List(fields.String()), default_factory=list
)
Running mypy
gives the following error:
blah.py: note: In class "Foo":
blah.py:10:34: error: Incompatible types in assignment (expression has type "Field[Any]", variable has type "List[str]") [assignment]
list_of_strings: List[str] = desert.field(
^
Found 1 error in 1 file (checked 1 source file)
Is there any way we can make the desert field return type match what we have specified?
https://github.com/python-desert/desert/blob/631de5f98d0f3edd3ecbab57100c5664a43bf3d5/src/desert/__init__.py#L55-L66
Below is my attempt to minimally recreate the issue and show some not-working options and output.
https://mypy-play.net/?mypy=latest&python=3.8&flags=strict%2Ccheck-untyped-defs&gist=7956a372fa34375077012351364a3aec