Skip to content

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

Merged
merged 4 commits into from
May 10, 2025

Conversation

max-muoto
Copy link
Contributor

@max-muoto max-muoto commented May 10, 2025

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.

max-muoto added 2 commits May 10, 2025 02:43
…on. Adjust type aliasing for better type safety in CSV quoting options.
@max-muoto max-muoto changed the title Accurate QuotingType for csv Module Use literal constant for QuotingType in csv Module May 10, 2025

This comment has been minimized.

Copy link
Collaborator

@srittau srittau left a 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.

@python python deleted a comment May 10, 2025
@python python deleted a comment May 10, 2025
@python python deleted a comment May 10, 2025
@python python deleted a comment May 10, 2025
@python python deleted a comment May 10, 2025
@max-muoto
Copy link
Contributor Author

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

Copy link
Contributor

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]

@srittau srittau merged commit ffc5acb into python:main May 10, 2025
64 checks passed
max-muoto added a commit to max-muoto/typeshed that referenced this pull request May 10, 2025
mmingyu pushed a commit to mmingyu/typeshed that referenced this pull request May 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants