Sourcery

Somewhere a year ago I stumped upon the tool called Sourcery. It is a great tool for refactoring your code. It can be used as a plugin for PyCharm, Vs Code.

look at the action below Sourcery gif

# Before
def is_even(num):
    if num % 2 == 0:
        return True
    else:
        return False

# After
def is_even(num):
    return num % 2 == 0

it can also scan for low code quality and suggest to extract methods, remove unused variables, etc.

they have a lot of refactoring options, and you can even create your own refactoring rules. they have 3 tiers

  • Free
  • Pro
  • Team

even the free tier is great.

you can check it out here Sourcery