Sourcery Pro launched
You can now purchase a Sourcery Pro subscription.
With Sourcery Pro you can:
- Remove duplicate code with our new automated method extraction
- Refactor your whole project in the IDE
- Use our GitHub bot on private repos
- Find duplicate code across your project (VS Code only at present)
Get more details here.
Duplicate code detection
You can now select multiple files or folders and scan for duplicated code within them. This will find sections of code that are 3 lines long or greater that are duplicated in multiple places. It will also find near-duplicate code where variable names have been changed but the code structure remains the same.
This feature is available in our Pro subscription, for VS Code users only initially. It is in active development so we would love your feedback.
Sourcery is now available in Sublime.
Get more details and setup instructions here.
Use str.join() instead of for loop: use-join
This will convert code like this:
result = "" for text in long_list_of_text(): result = result + text return result
result = "".join(long_list_of_text()) return result
Simplify Constant Sum: simplify-constant-sum
results = sum(1 for token in source.split() if token == 1)
results = sum(token == 1 for token in source.split())
simplify-boolean-comparisonsuggest more often
use-countnow triggers on the result of
simplify-constant-sumrather than directly
remove-redundant-ifnow slightly more powerful
- Improved handling of
if..elifchains with repeated code
remove-redundant-ifwhen invalidated by a context manager
- Fix issue where
switchrefactoring could produce incorrect result
- Fix issue with hoisting statements from loops which could produce incorrect results
- Fixed issue in PyCharm where Sourcery could lose connection to binary when it was scanning a very large function.