-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Consider with statements for too many branches lint (#11321)
Resolves #11313 ## Summary PLR0912(too-many-branches) did not count branches inside with: blocks. With this fix, the branches inside with statements are also counted. ## Test Plan Added a new test case.
- Loading branch information
Showing
3 changed files
with
65 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
27 changes: 17 additions & 10 deletions
27
...les/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0912_too_many_branches.py.snap
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,21 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/pylint/mod.rs | ||
--- | ||
too_many_branches.py:6:5: PLR0912 Too many branches (13 > 12) | ||
| | ||
4 | """ | ||
5 | # pylint: disable=using-constant-test | ||
6 | def wrong(): # [too-many-branches] | ||
| ^^^^^ PLR0912 | ||
7 | """ Has too many branches. """ | ||
8 | if 1: | ||
| | ||
|
||
too_many_branches.py:8:5: PLR0912 Too many branches (13 > 12) | ||
| | ||
7 | # pylint: disable=using-constant-test | ||
8 | def wrong(): # [too-many-branches] | ||
| ^^^^^ PLR0912 | ||
9 | """ Has too many branches. """ | ||
10 | if 1: | ||
| | ||
|
||
too_many_branches.py:76:5: PLR0912 Too many branches (13 > 12) | ||
| | ||
74 | pass | ||
75 | | ||
76 | def with_statement_wrong(): | ||
| ^^^^^^^^^^^^^^^^^^^^ PLR0912 | ||
77 | """statements inside the with statement should get counted""" | ||
78 | with suppress(Exception): | ||
| |