This new release greatly improves the type checking capabilities of Refurb. You might find that you are getting a lot more errors in your projects, as well as a few false positives. Please report any incorrect changes you might find!
Add better type deduction
Refurb now makes better use of Mypy's type deduction system, allowing Refurb to find more errors and with better accuracy.
For example, the following is not detected in older versions of Refurb:
nums = [[]]
if len(nums[0]):
print("nums[0] is not empty")
With this new version of Refurb, the type of nums[0] is inferred as a list:
$ refurb file.py
file.py:3:4 [FURB115]: Replace `len(nums[0])` with `nums[0]`
While this new type deduction is a great improvement on what existed before, there is still a lot of room for improvement. If you find any typing related bugs, please report it!
Add use-isinstance-bool check (FURB191)
Don't check if a value is True or False using in, use an isinstance() call.
Bad:
if value in {True, False}:
pass
Good:
if isinstance(value, bool):
pass
Add use-str-method check (FURB190)
Don't use a lambda function to call a no-arg method on a string, use the name of the string method directly. It is faster, and often times improves readability.
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Updates the requirements on refurb to permit the latest version.
Release notes
Sourced from refurb's releases.
... (truncated)
Commits
2e31f00
Release v2d4e9ee3
Add better type deduction for sets, frozensets, and tuples to FURB115ae0e502
Bump dev packagesee2daae
Addos.environ
to copy-able mapping type list85ef890
Adduse-isinstance-bool
check43c63c8
Add better detection and error messages for len compatible types in FURB115 (...d8ec9f4
Add better type deduction for mapping typesc30b449
Add type deduction for type aliases6b9035f
Fix incorrect error message for FURB12260bb2f6
Fix newlines being printed in stringified stringsDependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting
@dependabot rebase
.Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show