Version 1.14.0
This PR includes a few bug fixes, a few new features, and 4 new checks!
Bug Fixes
- Error codes can be comma separated in
noqa
comments now - Unused fields or fields with the wrong type will throw an error now
New Features
- Add ability to output GitHub Annotations using
--format github
- Add ability to sort error output by error code via
--sort error
Add simplify-math-log
check (FURB163)
Use the shorthand log2
and log10
functions instead of passing 2 or 10 as the second argument to the log
function. If math.e
is used as the second argument, just use math.log(x)
instead, since e
is the default.
Bad:
power = math.log(x, 10)
Good:
power = math.log10(x)
Add no-from-float
check (FURB164)
When constructing a Fraction or Decimal using a float, don't use the from_float()
or from_decimal()
class methods: Just use the more consice Fraction()
and Decimal()
class constructors instead.
Bad:
ratio = Fraction.from_float(1.2)
score = Decimal.from_float(98.0)
Good:
ratio = Fraction(1.2)
score = Decimal(98.0)
Add no-temp-class-object
check (FURB165)
You don't need to construct a class object to call a static method or a class method, just invoke the method on the class directly:
Bad:
cwd = Path().cwd()
Good:
cwd = Path.cwd()
Add use-int-base-zero
check (FURB166)
When converting a string starting with 0b
, 0o
, or 0x
to an int, you don't need to slice the string and set the base yourself: just call int()
with a base of zero. Doing this will autodeduce the correct base to use based on the string prefix.
Bad:
num = "0xABC"
if num.startswith("0b"):
i = int(num[2:], 2)
elif num.startswith("0o"):
i = int(num[2:], 8)
elif num.startswith("0x"):
i = int(num[2:], 16)
print(i)
Good:
num = "0xABC"
i = int(num, 0)
print(i)
This check is disabled by default because there is no way for Refurb to detect whether the prefixes that are being stripped are valid Python int prefixes (like 0x
) or some other prefix which would fail if parsed using this method.
What's Changed
- Add
simplify-math-log
check by @dosisod in #213 - Allow for multiple error codes in
noqa
comments by @dosisod in #218 - Error when unknown field is found in config file by @dosisod in #219
- Add type checking for fields in config file by @dosisod in #220
- Bump versions by @dosisod in #223
- Add
no-from-float
check by @dosisod in #224 - Add better type inference by @dosisod in #225
- Add output format for GitHub Annotations by @dosisod in #226
- Add
no-temp-class-object
check by @dosisod in #227 - Add
use-int-base-zero
check by @dosisod in #228 - Add
--sort
flag by @dosisod in #229 - Autogenerate documentation for checks by @dosisod in #230
- Bump packages by @dosisod in #231
- Release v1.14.0 by @dosisod in #232
Full Changelog: v1.13.0...v1.14.0