Skip to content

Commit

Permalink
Fix documentation errors:
Browse files Browse the repository at this point in the history
Closes #298.

Mypy 1.6.0 dropped support for Python 3.6, so I updated the README to mention
this. While Refurb works with a wide variety of Mypy versions, it is hard to
guarantee that Refurb has support for every possible Python version Mypy
supports, so I'm opting to go with the lowest common denominator.
  • Loading branch information
dosisod committed Oct 19, 2023
1 parent 6db8eb5 commit e846d72
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ $ refurb file.py folder/
```

> **Note**
> Refurb must be ran on Python 3.10+, though it can check Python 3.6+ code by setting the `--python-version` flag.
> Refurb must be ran on Python 3.10+, though it can check Python 3.7+ code by setting the `--python-version` flag.
## Explanations For Checks

Expand Down
8 changes: 6 additions & 2 deletions refurb/checks/itertools/use_chain_from_iterable.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
@dataclass
class ErrorInfo(Error):
"""
When flattening an list of lists, use the `chain.from_iterable` function
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.
Expand Down Expand Up @@ -43,9 +43,13 @@ class ErrorInfo(Error):
rows = [[1, 2], [3, 4]]
flat = chain.from_iterable(*rows)
flat = chain.from_iterable(rows)
```
Note: `chain.from_iterable()` returns an iterator, which means you might
need to wrap it in `list()` depending on your use case. Refurb cannot
detect this (yet), so this is something you will need to keep in mind.
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.
Expand Down

0 comments on commit e846d72

Please sign in to comment.