github dosisod/refurb v1.5.0
Version 1.5.0

latest releases: v2.0.0, v1.28.0, v1.27.0...
2 years ago

Since the last release, many flags and checks have been added, and of course, lots of bugs have been fixed as well!

FURB120 is now disabled by default

Due to popular demand, FURB120 has been disabled by default. If you wish to continue using it, you will need to enable it.

The --enable-all and --disable-all flags

Two new flags have been added, --enable-all and --disable-all. As the names imply, they will enable or disable all checks. The "enable all" option is good for new codebases which want to opt-in to all available checks, whereas "disable all" can be good for existing codebases which need to be incrementally cleaned up.

Read the docs for more info.

The --python-version flag

This flag can be used to specify what version of Python your codebase is using. This allows for Mypy to better type check your code, and also allows for more useful error messages. When specifying this flag, it must be in the form X.Y, such as 3.9 or 3.10.

The "no trailing continue" check

Similar to the "no trailing return" check, this check applies to instances where the continue keyword is not needed:

for num in range(10):
    print(num)

    continue

Here, the continue is not needed, because we are already at the end of the for loop.

The "use @cache decorator" check

Python 3.9 introduced the @cache decorator, which is a shorthand for @lru_cache(maxsize=None). Refurb will now suggest that you change this:

from functools import lru_cache

@lru_cache(maxsize=None)
def f(x: int) -> int:
    return x + 1

To this:

from functools import cache

@cache
def f(x: int) -> int:
    return x + 1

If you are using Python 3.9+.

What's Changed

New Contributors

Full Changelog: v1.4.0...v1.5.0

Don't miss a new refurb release

NewReleases is sending notifications on new releases.