dataclass-csv icon indicating copy to clipboard operation
dataclass-csv copied to clipboard

Fix keyword argument type in DataclassWriter

Open medovina opened this issue 2 years ago • 1 comments

If I try to create a DataclassWriter with the keyword argument delimiter = ';', Python's type checker (I'm using Pyright) will report this error:

Argument of type "Literal[';']" cannot be assigned to parameter "delimiter" of type "Dict[str, Any]" in function "__init__"
  "Literal[';']" is incompatible with "Dict[str, Any]"

This pull request contains a simple fix.

medovina avatar Aug 10 '23 12:08 medovina

I was facing this issue as well, which is due to the specific type hint for args and kwargs: https://stackoverflow.com/questions/37031928/type-annotations-for-args-and-kwargs

I released an updated version (with up-to-date tooling) of the lib which includes this fix a dataclass-csv2 on pypi, (repo). Hopefully if/when the maintainer become active again I could merge back to upstream.

kraktus avatar Jan 26 '25 11:01 kraktus