The Sourcery CLI can give suggestions and comments - plus a number of new refactorings
Added
-
The Sourcery CLI now includes a
reviewcommand. Use this to get Sourcery to give suggestions and comments in addition to standard refactorings. Commented lines will be highlighted in red. -
break-or-continue-outside-looprefactoring -
class-method-first-arg-namerefactoring -
collection-to-boolrefactoring -
compare-via-equalssuggestion -
dict-assign-update-to-unionrefactoring -
do-no-use-bare-exceptsuggestion -
hoist-repeated-if-conditionrefactoring -
simplify-single-exception-tuplerefactoring -
remove-redundant-booleanrefactoring -
remove-redundant-constructor-in-dict-unionrefactoring -
remove-redundant-exceptionrefactoring -
return-or-yield-outside-functionrefactoring -
use-getitem-for-re-match-groupsrefactoring -
use-dictionary-unionrefactoring -
while-guard-to-conditionrefactoring
Changed
-
Add removal of bools to
remove-unnecessary-cast -
The remove-duplicate-key refactoring was split into a refactoring
remove-duplicate-set-keyand a suggestionremove-duplicate-dict-key -
remove-duplicate-dict-keywas enhanced to handle unpacked dictionaries -
remove-duplicate-dict-keyandremove-duplicate-set-keywere enhanced to refactor dicts and sets in any context (previously they were only applied in assignments). -
simplify-len-comparisonwill now also simplify len(s) < 0 as False and len(s) >= 0 as True -
raise-specific-errorwill now also cover raising BaseException and raising from other exceptions
Fixed
-
Comments will now show on the correct line where there are functions with docstrings. Addresses issue #211
-
F-strings containing escaped characters will not be refactored into constant strings. Addresses issue #213.
-
str-prefix-suffixnow triggers in the correct way for applyingendswith -
use-assigned-var: Do not apply if the variable is overwritten in a loop -
use-itertools-productwill now combine nested products. Fixes issue #214. -
We now assume
anyandallwrite to their arguments, since they exhaust iterators. This fixes issue #210