-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Fix _csv.Dialect.__init__
#12320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix _csv.Dialect.__init__
#12320
Conversation
All props can be passed to `__init__` as pos-or-keyword: ```python >>> _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> ```
This comment has been minimized.
This comment has been minimized.
Ok, I see: |
See #3613 for why this was added. |
Do you still want to change anything here? CI is failing. |
We want:
I can make |
This comment has been minimized.
This comment has been minimized.
@JelleZijlstra thanks for the reminder! |
def __init__(self) -> None: ... | ||
|
||
_DialectLike: TypeAlias = str | Dialect | type[Dialect] | ||
def __init__( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be __new__
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is __new__
for _csv.Dialect
, but __init__
for csv.Dialect
. I feel safer to use __init__
in both cases.
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
All props can be passed to
__init__
as pos-or-keyword:Source: https://github.com/python/cpython/blame/e6264b44dc7221c713b14dfa0f5929b33d362829/Modules/_csv.c#L389