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