-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Use literal constant for QuotingType
in csv
Module
#13983
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
Conversation
…on. Adjust type aliasing for better type safety in CSV quoting options.
QuotingType
for csv
ModuleQuotingType
in csv
Module
This comment has been minimized.
This comment has been minimized.
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.
Thanks, some projects will need to update their annotations, but that's acceptable to me. But in general we only add tests for complex annotations. These annotations look straight forward enough for me that we don't need tests.
Removed: 95d040d |
Diff from mypy_primer, showing the effect of this PR on open source code: pandas (https://github.com/pandas-dev/pandas)
+ pandas/io/formats/csvs.py:264: error: Argument "quoting" to "writer" has incompatible type "int"; expected "Literal[0, 1, 2, 3]" [arg-type]
static-frame (https://github.com/static-frame/static-frame)
+ static_frame/core/frame.py:9096: error: Argument "quoting" to "writer" has incompatible type "int"; expected "Literal[0, 1, 2, 3, 4, 5]" [arg-type]
|
The mentioned moratorium is long over (#7258), and similar literals constants are commonly used in TypeShed at this point. Unless there's a major point of objection, and the fact that in most cases the constants are being directly passed into
csv.writer(...)
the chance of false positives is pretty low.