-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[flake8-pytest-style] Do not emit diagnostics for empty for loops (PT012, PT031)
#15542
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… (`PT012`, `PT031`)
Contributor
|
charliermarsh
approved these changes
Jan 17, 2025
Member
charliermarsh
left a comment
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.
Nice, thank you.
dcreager
added a commit
that referenced
this pull request
Jan 17, 2025
* main: [red-knot] Inline `SubclassOfType::as_instance_type_of_metaclass()` (#15556) [`flake8-comprehensions`] strip parentheses around generators in `unnecessary-generator-set` (`C401`) (#15553) [`pylint`] Implement `redefined-slots-in-subclass` (`W0244`) (#9640) [`flake8-bugbear`] Do not raise error if keyword argument is present and target-python version is less or equals than 3.9 (`B903`) (#15549) [red-knot] `type[T]` is disjoint from `type[S]` if the metaclass of `T` is disjoint from the metaclass of `S` (#15547) [red-knot] Pure instance variables declared in class body (#15515) Update snapshots of #15507 with new annotated snipetts rendering (#15546) [`pylint`] Do not report methods with only one `EM101`-compatible `raise` (`PLR6301`) (#15507) Fix unstable f-string formatting for expressions containing a trailing comma (#15545) Support `knot.toml` files in project discovery (#15505) Add support for configuring knot in `pyproject.toml` files (#15493) Fix bracket spacing for single-element tuples in f-string expressions (#15537) [`flake8-simplify`] Do not emit diagnostics for expressions inside string type annotations (`SIM222`, `SIM223`) (#15405) [`flake8-pytest-style`] Do not emit diagnostics for empty `for` loops (`PT012`, `PT031`) (#15542)
MichaReiser
added a commit
that referenced
this pull request
Mar 13, 2025
…PT031`) (#16678) ## Summary This PR stabilizes the behavior change introduced in #15542 to allow for statements with an empty body in `pytest.raises` and `pytest.warns` with statements. This raised an error before but is now allowed: ```py with pytest.raises(KeyError, match='unknown'): async for _ in gpt.generate(gpt_request): pass ``` The same applies to ```py with pytest.raises(KeyError, match='unknown'): async for _ in gpt.generate(gpt_request): ... ``` There have been now new issues or PRs related to PT012 or PT031 since this behavior change was introduced in ruff 0.9.3 (January 23rd).
MichaReiser
added a commit
that referenced
this pull request
Mar 13, 2025
…PT031`) (#16678) ## Summary This PR stabilizes the behavior change introduced in #15542 to allow for statements with an empty body in `pytest.raises` and `pytest.warns` with statements. This raised an error before but is now allowed: ```py with pytest.raises(KeyError, match='unknown'): async for _ in gpt.generate(gpt_request): pass ``` The same applies to ```py with pytest.raises(KeyError, match='unknown'): async for _ in gpt.generate(gpt_request): ... ``` There have been now new issues or PRs related to PT012 or PT031 since this behavior change was introduced in ruff 0.9.3 (January 23rd).
MichaReiser
added a commit
that referenced
this pull request
Mar 13, 2025
…PT031`) (#16678) ## Summary This PR stabilizes the behavior change introduced in #15542 to allow for statements with an empty body in `pytest.raises` and `pytest.warns` with statements. This raised an error before but is now allowed: ```py with pytest.raises(KeyError, match='unknown'): async for _ in gpt.generate(gpt_request): pass ``` The same applies to ```py with pytest.raises(KeyError, match='unknown'): async for _ in gpt.generate(gpt_request): ... ``` There have been now new issues or PRs related to PT012 or PT031 since this behavior change was introduced in ruff 0.9.3 (January 23rd).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Resolves #9730.
Test Plan
cargo nextest runandcargo insta test.