[flake8-logging] Stabilize log-exception-outside-except-handler (LOG004)#18603
Closed
ntBre wants to merge 14 commits into
Closed
[flake8-logging] Stabilize log-exception-outside-except-handler (LOG004)#18603ntBre wants to merge 14 commits into
flake8-logging] Stabilize log-exception-outside-except-handler (LOG004)#18603ntBre wants to merge 14 commits into
Conversation
…18496) Note that the preview behavior was not documented (shame on us!) so the documentation was not modified. --------- Co-authored-by: Brent Westbrook <[email protected]>
…eral-concatenation` (`RUF005`) (#18500)
This PR stabilizes the RUF053 rule by moving it from preview to stable status for the 0.12.0 release. ## Summary - **Rule**: RUF053 (`class-with-mixed-type-vars`) - **Purpose**: Detects classes that have both PEP 695 type parameter lists while also inheriting from `typing.Generic` - **Change**: Move from `RuleGroup::Preview` to `RuleGroup::Stable` in `codes.rs` and migrate preview tests to stable tests ## Verification Links - **Tests**: [ruff/mod.rs](https://github.com/astral-sh/ruff/blob/main/crates/ruff_linter/src/rules/ruff/mod.rs#L98) - Shows RUF053 moved from preview_rules to main rules test function - **Documentation**: https://docs.astral.sh/ruff/rules/class-with-mixed-type-vars/ - Current documentation shows preview status that will be automatically updated
This PR stabilizes the FURB162 rule by moving it from preview to stable status for the 0.12.0 release. ## Summary - **Rule**: FURB162 (`fromisoformat-replace-z`) - **Purpose**: Detects unnecessary timezone replacement operations when calling `datetime.fromisoformat()` - **Change**: Move from `RuleGroup::Preview` to `RuleGroup::Stable` in `codes.rs` ## Verification Links - **Tests**: [refurb/mod.rs](https://github.com/astral-sh/ruff/blob/main/crates/ruff_linter/src/rules/refurb/mod.rs#L54) - Confirms FURB162 has only standard tests, no preview-specific test cases - **Documentation**: https://docs.astral.sh/ruff/rules/fromisoformat-replace-z/ - Current documentation shows preview status that will be automatically updated
…sions in autofix for `if-else-block-instead-of-if-exp` (`SIM108`) (#18506)
…` (`RUF100`) (#18497) Note that the preview behavior was not documented (shame on us!) so the documentation was not modified. --------- Co-authored-by: Brent Westbrook <[email protected]>
…t-shell-equals-true` (`S603`) (#18521)
…ype-hint-positional-argument` (`FBT001`) (#18520) Feel free to complain about the rephrasing in the docs!
## Summary Stabilizes the UP049 rule (private-type-parameter) by moving it from Preview to Stable. UP049 detects and fixes the use of private type parameters (those with leading underscores) in PEP 695 generic classes and functions. ## Test plan - Verified that UP049 tests pass: `crates/ruff_linter/src/rules/pyupgrade/mod.rs` - Ran full test suite with `make test` - Confirmed that no test migration was needed as UP049 was already in the main `rules` test function ## Rule documentation https://docs.astral.sh/ruff/rules/private-type-parameter/
…`LOG004`) Summary -- Stabilizes LOG004 and updates the documentation to say explicitly that the rule still triggers even when passing the `exc_info` kwarg (#18044). Test Plan -- Existing tests, which were already in the right place
Contributor
|
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| LOG004 | 25 | 25 | 0 | 0 | 0 |
| RUF100 | 1 | 0 | 1 | 0 | 0 |
Linter (preview)
✅ ecosystem check detected no linter changes.
Contributor
Author
|
I think this example might be a false positive: It looks like a closure defined in the except handler will preserve its >>> import logging
>>> l = []
>>> def foo(f): f()
...
>>> try:
... raise ValueError("my error")
... except ValueError:
... logging.exception("building on_failure")
... def on_failure():
... logging.exception("on_failure called")
... foo(on_failure)
... l.append(on_failure)
...
ERROR:root:building on_failure
Traceback (most recent call last):
File "<python-input-19>", line 2, in <module>
raise ValueError("my error")
ValueError: my error
ERROR:root:on_failure called
Traceback (most recent call last):
File "<python-input-19>", line 2, in <module>
raise ValueError("my error")
ValueError: my error
>>> l[-1]()
ERROR:root:on_failure called
NoneType: Nonebut not if you store it somewhere else and call it later. |
Contributor
Author
|
What do you think about the false positive? This is the last LOG rule in preview, but my first thought was to leave it in preview even before this, so I'm happy to leave it for now. |
aaf6c9b to
96913d1
Compare
3ad0f1f to
ff6fb14
Compare
Collaborator
|
I vote to leave it in preview and address the bug! |
Contributor
Author
|
Sounds good to me, thanks for opening the issue! |
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
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
Stabilizes LOG004 and updates the documentation to say explicitly that the rule still triggers even when passing the
exc_infokwarg (#18044).Test Plan
Existing tests, which were already in the right place