Skip to content

[refactor] Tighten SetComparisonFunction to Iterator[str]#14587

Merged
Pierre-Sassoulas merged 1 commit into
pytest-dev:mainfrom
Pierre-Sassoulas:assertion-set-iterator-cleanup
Jun 13, 2026
Merged

[refactor] Tighten SetComparisonFunction to Iterator[str]#14587
Pierre-Sassoulas merged 1 commit into
pytest-dev:mainfrom
Pierre-Sassoulas:assertion-set-iterator-cleanup

Conversation

@Pierre-Sassoulas

Copy link
Copy Markdown
Member

Consensual changes prior to #14523:

  • drop the redundant : Iterator[str] annotation on source: every branch already produces an Iterator[str].
  • return Iterator[str] from SetComparisonFunction instead of Iterable[str] so the call site no longer needs iter(...); the != branch is promoted from a list-returning lambda to a named generator so the new contract holds.

Addresses review feedback on PR pytest-dev#14523:
* drop the redundant ``: Iterator[str]`` annotation on ``source`` —
  every branch already produces an ``Iterator[str]``.
* return ``Iterator[str]`` from ``SetComparisonFunction`` instead of
  ``Iterable[str]`` so the call site no longer needs ``iter(...)``;
  the ``!=`` branch is promoted from a list-returning lambda to a
  named generator so the new contract holds.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Pierre-Sassoulas Pierre-Sassoulas added the skip news used on prs to opt out of the changelog requirement label Jun 13, 2026
@Pierre-Sassoulas Pierre-Sassoulas merged commit 368d2fc into pytest-dev:main Jun 13, 2026
36 checks passed
@Pierre-Sassoulas Pierre-Sassoulas deleted the assertion-set-iterator-cleanup branch June 13, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news used on prs to opt out of the changelog requirement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants