KEMBAR78
Use literal constant for `QuotingType` in `csv` Module by max-muoto · Pull Request #13983 · python/typeshed · GitHub
Skip to content

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
@github-actions

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

@github-actions
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