-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[flake8-logging] Stabilize log-exception-outside-except-handler (LOG004)
#18603
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
Conversation
…18496) Note that the preview behavior was not documented (shame on us!) so the documentation was not modified. --------- Co-authored-by: Brent Westbrook <brentrwestbrook@gmail.com>
…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 <brentrwestbrook@gmail.com>
…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
|
| 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.
|
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. |
|
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
|
I vote to leave it in preview and address the bug! |
|
Sounds good to me, thanks for opening the issue! |
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