github dosisod/refurb v1.6.0
Version 1.6.0

latest releases: v2.0.0, v1.28.0, v1.27.0...
22 months ago

This version primarily just fixes bugs, but also includes a new check.

FURB106, the "expandtabs" check, is disabled by default now

Turns out .replace("\t", 8 * " ") is not the same as .expandtabs(): the replace version will replace every tab with exactly 8 spaces, but the expandtabs version will replace each tab with spaces up to the nearest tab stop. If your tabs are only at the start of a string, this works as expected! But, if they are in the middle of the string, this behavior might not be what you want. For this reason, it has been disabled by default. Read the docs for more information on how to enable checks.

Add the "no ignored dict items" check (FURB135)

The items() method on dict objects allow you to iterate over all the key-value pairs in a dictionary. If you only need the key or value, but not both, you shouldn't use items(), but instead use the specific values() and keys() methods. For example, Refurb will suggest that this:

books = {"Frank Herbert": "Dune"}

for author, _ in books.items():
    print(author)

for _, book in books.items():
    print(book)

Should be changed to this:

books = {"Frank Herbert": "Dune"}

for author in books:
    print(author)

for book in books.values():
    print(book)

What's Changed

  • Add "no ignored dict items" check by @dosisod in #95
  • Improve and disable the expandtabs() check by @dosisod in #96
  • Add better node equivalence checks: by @dosisod in #98
  • Bump packages by @dosisod in #105
  • Add more strict type checking for check functions and Error subclasses by @dosisod in #106
  • Update and improve error messages by @dosisod in #107
  • Also mention another type checker Pytype. by @yilei in #108
  • Add categories to checks by @dosisod in #109

New Contributors

Full Changelog: v1.5.0...v1.6.0

Don't miss a new refurb release

NewReleases is sending notifications on new releases.