Fix `_csv.Dialect.__init__`
All props can be passed to __init__ as pos-or-keyword:
>>> _csv.Dialect(1)
<_csv.Dialect object at 0x106604d70>
>>> _csv.Dialect(dialect=1)
<_csv.Dialect object at 0x106605d90>
>>> _csv.Dialect(delimiter='.')
<_csv.Dialect object at 0x106605790>
>>> _csv.Dialect(quotechar='.')
<_csv.Dialect object at 0x106605970>
>>> _csv.Dialect(quotechar=None)
<_csv.Dialect object at 0x106605850>
Source: https://github.com/python/cpython/blame/e6264b44dc7221c713b14dfa0f5929b33d362829/Modules/_csv.c#L389
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉
Ok, I see: # actually csv.Dialect is a different class to _csv.Dialect at runtime, but for typing purposes, they're identical
See #3613 for why this was added. csv.Dialect looks to be a weird hack at runtime, probably back from a time when C classes couldn't be sub-classed by Python code.
Do you still want to change anything here? CI is failing.
We want:
- "Base class"
_csv.Dialectmust have__init__with parameters - "Child class"
csv.Dialectmust have__init__(self)
I can make csv.Dialect a subclass of _csv.Dialect and make unsafe __init__ redefinition with type ignores. Will try that :)
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉
@JelleZijlstra thanks for the reminder!
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉