dfurtado / dataclass-csv

Map CSV to Data Classes
Other
195 stars 21 forks source link

Type annotations for *args and **kwds #46

Closed gschwaer closed 2 years ago

gschwaer commented 2 years ago

The type annotations for the DataclassReader are incorrect:

https://github.com/dfurtado/dataclass-csv/blob/872ce021fcda12bc0ccad8fd7719036dc0d87e4c/dataclass_csv/dataclass_reader.py#L48-L59

https://github.com/dfurtado/dataclass-csv/blob/872ce021fcda12bc0ccad8fd7719036dc0d87e4c/dataclass_csv/dataclass_reader.pyi#L5-L16

Even though *args and **kwds are technically a List and a Dict respectively, they are not typed the same way. See mypy docs or PEP-484. Changing both to Any solves this problem.

Mypy output when calling the DataclassReader Ctor:

reader = DataclassReader(
    lines,
    MyDataclass,
    delimiter="+",
#             ^ Argument "delimiter" to "DataclassReader" has incompatible type "str"; expected "Dict[str, Any]"
)
dfurtado commented 2 years ago

Hi @gschwaer

Thank you so much for reporting this issue. I will look into it and push a new release asap.

//Daniel

gschwaer commented 2 years ago

Hi Daniel, much appreciated. If I can help, let me know.