Refurb

Latest version: v2.0.0

Safety actively analyzes 687918 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 2 of 6

1.23.0

This is a minor patch that pins Mypy to version <1.7.0, see 305 for more info.

What's Changed
* Pin Mypy to <1.7.0 by dosisod in https://github.com/dosisod/refurb/pull/306


**Full Changelog**: https://github.com/dosisod/refurb/compare/v1.22.2...v1.23.0

1.22.2

This is a bug fix release that fixes crashes on certain files.

What's Changed
* Skip files that raise `RecursionError` by dosisod in https://github.com/dosisod/refurb/pull/304

**Full Changelog**: https://github.com/dosisod/refurb/compare/v1.22.1...v1.22.2

1.22.1

This is a minor patch that fixes some typos and improves the accuracy of emitted error messages for FURB140 and FURB179.

What's Changed
* Fix documentation errors by dosisod in https://github.com/dosisod/refurb/pull/299
* Add better detection of list/set comprehensions by dosisod in https://github.com/dosisod/refurb/pull/300

**Full Changelog**: https://github.com/dosisod/refurb/compare/v1.22.0...v1.22.1

1.22.0

This version adds 2 new checks, some bug fixes, and documentation fixes.

Improved Error Messages

Previously Refurb would assume certain identifiers such as `Path` where imported as `Path`, not `pathlib.Path`. This made the context of error messages less helpful since they did not reflect what was actually in the source. Now more checks will use the more accurate `pathlib.Path` identifier if needed.

Add `use-chain-from-iterable` check (FURB179)

When flattening a list of lists, use the `chain.from_iterable` function from the `itertools` stdlib package. This function is faster than native list/generator comprehensions or using `sum()` with a list default.

Bad:

python
from itertools import chain

rows = [[1, 2], [3, 4]]

using list comprehension
flat = [col for row in rows for col in row]

using sum()
flat = sum(rows, [])

using chain(*x)
flat = chain(*rows)


Good:

python
from itertools import chain

rows = [[1, 2], [3, 4]]

flat = chain.from_iterable(rows)


> Note: `chain(*x)` may be marginally faster/slower depending on the length of `x`. Since `*` might potentially expand to a lot of arguments, it is better to use `chain.from_iterable()` when you are unsure.

Add `use-abc-shorthand` check (FURB180)

Instead of setting `metaclass` directly, inherit from the `ABC` wrapper class. This is semantically the same thing, but more succinct.

Bad:

python
class C(metaclass=ABCMeta):
pass


Good:

python
class C(ABC):
pass


What's Changed
* Don't emit FURB120 when deleting default arg would change semantics by dosisod in https://github.com/dosisod/refurb/pull/289
* Update docs for FURB107 (`use-suppress`) by dosisod in https://github.com/dosisod/refurb/pull/292
* Add `use-chain-from-iterable` check by dosisod in https://github.com/dosisod/refurb/pull/293
* Tweak versioning docs, bump packages by dosisod in https://github.com/dosisod/refurb/pull/294
* Fix failing test in Mypy 1.6.0 by dosisod in https://github.com/dosisod/refurb/pull/296
* Bump packages, bump version by dosisod in https://github.com/dosisod/refurb/pull/297


**Full Changelog**: https://github.com/dosisod/refurb/compare/v1.21.0...v1.22.0

1.21.0

This version adds some small bug fixes and improvements to certain checks.

What's Changed
* Add example config files by dosisod in https://github.com/dosisod/refurb/pull/280
* Fix tests failing in Python 3.12 by dosisod in https://github.com/dosisod/refurb/pull/281
* Detect `not` when used with `startswith` and `endswith` by dosisod in https://github.com/dosisod/refurb/pull/282
* Only allow built-in mapping types in FURB173 by dosisod in https://github.com/dosisod/refurb/pull/284
* Improve FURB111, bump version by dosisod in https://github.com/dosisod/refurb/pull/285


**Full Changelog**: https://github.com/dosisod/refurb/compare/v1.20.0...v1.21.0

1.20.0

This is a small release that should address some of the slowness in Refurb. More speedups coming soon!

Speedup Refurb

There was a small bug in Refurb where it would reload all the checks for each file when it only needed to do it once at the beginning. After fixing this, running Refurb against itself is about 1 second (~10%) faster now. Your mileage my vary, but codebases with more files will benefit more from this fix.

Add `--timing-stats` flag

This flag will dump a bunch of timing information to a JSON file for diagnosing speed issues. Read [the docs](https://github.com/dosisod/refurb#troubleshooting) for more info.

What's Changed
* fix(no_unnecessary_cast): fix typo in shallow by ChaoticRoman in https://github.com/dosisod/refurb/pull/278

**Full Changelog**: https://github.com/dosisod/refurb/compare/v1.19.0...v1.20.0

Page 2 of 6

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.