Skip to content
This repository has been archived by the owner on Jul 19, 2024. It is now read-only.

chore(deps): update dependency refurb to v2 #239

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

renovate[bot]
Copy link

@renovate renovate bot commented Apr 24, 2024

Mend Renovate

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
refurb ^1.16.0 -> ^2.0.0 age adoption passing confidence

Release Notes

dosisod/refurb (refurb)

v2.0.0

Compare Source

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.

Bad:

def normalize_phone_number(phone_number: str) -> int:
    digits = filter(lambda x: x.isdigit(), phone_number)

    return int("".join(digits))

Good:

def normalize_phone_number(phone_number: str) -> int:
    digits = filter(str.isdigit, phone_number)

    return int("".join(digits))

Add no-subclass-builtin check (FURB189)

Note: this check is disabled by default, see below.

Subclassing dict, list, or str objects can be error prone, use the UserDict, UserList, and UserStr objects from the collections module instead.

Bad:

class CaseInsensitiveDict(dict):
    ...

Good:

from collections import UserDict

class CaseInsensitiveDict(UserDict):
    ...

Note: isinstance() checks for dict, list, and str types will fail when using the corresponding User class. If you need to pass custom dict or list objects to code you don't control, ignore this check. If you do control the code, consider using the following type checks instead:

  • dict -> collections.abc.MutableMapping
  • list -> collections.abc.MutableSequence
  • str -> No such conversion exists

Rename no-del to use-clear (FURB131)

Read dbe3126 for more info. In short, FURB131 will now detect both of the following snippets:

nums = [[1, 2, 3], [4, 5, 6]]

nums[0][:] = []
del nums[0][:]

Running Refurb:

$ refurb file.py
file.py:3:1 [FURB131]: Replace `nums[0][:] = []` with `nums[0].clear()`
file.py:4:1 [FURB131]: Replace `del nums[0][:]` with `nums[0].clear()`

What's Changed

Full Changelog: dosisod/refurb@v1.28.0...v2.0.0


Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR has been generated by Mend Renovate. View repository job log here.

@renovate renovate bot requested a review from a team April 24, 2024 18:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants