The Sourcery CLI can give suggestions and comments - plus a number of new refactorings
Added
-
The Sourcery CLI now includes a
review
command. 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-loop
refactoring -
class-method-first-arg-name
refactoring -
collection-to-bool
refactoring -
compare-via-equals
suggestion -
dict-assign-update-to-union
refactoring -
do-no-use-bare-except
suggestion -
hoist-repeated-if-condition
refactoring -
simplify-single-exception-tuple
refactoring -
remove-redundant-boolean
refactoring -
remove-redundant-constructor-in-dict-union
refactoring -
remove-redundant-exception
refactoring -
return-or-yield-outside-function
refactoring -
use-getitem-for-re-match-groups
refactoring -
use-dictionary-union
refactoring -
while-guard-to-condition
refactoring
Changed
-
Add removal of bools to
remove-unnecessary-cast
-
The remove-duplicate-key refactoring was split into a refactoring
remove-duplicate-set-key
and a suggestionremove-duplicate-dict-key
-
remove-duplicate-dict-key
was enhanced to handle unpacked dictionaries -
remove-duplicate-dict-key
andremove-duplicate-set-key
were enhanced to refactor dicts and sets in any context (previously they were only applied in assignments). -
simplify-len-comparison
will now also simplify len(s) < 0 as False and len(s) >= 0 as True -
raise-specific-error
will 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-suffix
now triggers in the correct way for applyingendswith
-
use-assigned-var
: Do not apply if the variable is overwritten in a loop -
use-itertools-product
will now combine nested products. Fixes issue #214. -
We now assume
any
andall
write to their arguments, since they exhaust iterators. This fixes issue #210