-
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.
[
flake8-bugbear
] Add autofix for B006 (#6131)
## Summary Reopening of #4880 One open TODO as described in: #4880 (comment) FYI @charliermarsh seeing as you commented you wanted to do final review and merge. @konstin @dhruvmanila @MichaReiser as previous reviewers. # Old Description ## Summary Adds an autofix for B006 turning mutable argument defaults into None and setting their original value back in the function body if still `None` at runtime like so: ```python def before(x=[]): pass def after(x=None): if x is None: x = [] pass ``` ## Test Plan Added an extra test case to existing fixture with more indentation. Checked results for all old examples. NOTE: Also adapted the jupyter notebook test as this checked for B006 as well. ## Issue link Closes: #4693 --------- Co-authored-by: konstin <[email protected]>
- Loading branch information
Showing
6 changed files
with
449 additions
and
120 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
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
Oops, something went wrong.