Skip to content

Accept CSV fieldname iterators on Python 3.12+ - #16846

Open
vanshbarfiwala-lgtm wants to merge 1 commit into
python:mainfrom
vanshbarfiwala-lgtm:fix-csv-fieldnames-iterators
Open

vanshbarfiwala-lgtm wants to merge 1 commit into
python:mainfrom
vanshbarfiwala-lgtm:fix-csv-fieldnames-iterators

Conversation

@vanshbarfiwala-lgtm

Copy link
Copy Markdown
Contributor

Python 3.12 and later convert iterator-valued fieldnames to lists in csv.DictReader and csv.DictWriter, but the stubs reject these inputs. Accept iterators for those versions while preserving the earlier annotations.

Tested with mypy for Python 3.10, 3.12 and 3.15, and Ruff. Verified iterator behavior on Python 3.15 and checked the CPython 3.11 and 3.12 implementations.

OpenAI Codex assisted with this change.

@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@srittau srittau left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the tests. In typeshed, we only add regression tests for functions and classes which are known to have caused complex problems in the past, or where stubs are difficult to get right. 100% test coverage for typeshed is neither necessary nor desirable, as it would lead to code duplication.

See tests/REGRESSION.md for more information.

This branch has not been deployed

No deployments
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