Fixit Extra¶
Additional Fixit-derived rules that can be enabled separately.
Enable with:
enable = ["fixit-extra"]
Rule |
Message |
Python |
Autofix |
|---|---|---|---|
Multiple isinstance calls with the same target but different types can be collapsed into a single call with a tuple of types. |
Any |
Yes |
|
{deprecated} is deprecated, use {replacement} instead |
Any |
Yes |
|
Inheriting from object is a no-op. ‘class Foo:’ is just fine =) |
Any |
Yes |
|
Avoid using ‘or’ in an except block. For example:’except ValueError or TypeError’ only catches ‘ValueError’. Instead, use parentheses, ‘except (ValueError, TypeError)’ |
Any |
No |
|
Do not use arguments when calling super for the parent class. |
Any |
Yes |
|
f-string doesn’t have placeholders, remove redundant f-string. |
Any |
Yes |
|
— |
Any |
Yes |
|
— |
Any |
Yes |
|
String type hints are no longer necessary in Python, use the type identifier directly. |
Any |
Yes |
|
|
Any |
Yes |
|
“assertTrue” does not compare its arguments, use “assertEqual” or other appropriate functions. |
Any |
Yes |
|
Use assertIn/assertNotIn instead of assertTrue/assertFalse for inclusion check. |
Any |
Yes |
|
“assertTrue” and “assertFalse” are deprecated. Use “assertIsNotNone” and “assertIsNone” instead. |
Any |
Yes |
|
Use asyncio.sleep in async function |
Any |
No |
|
When using @classmethod, the first argument must be |
Any |
Yes |
|
ABCs must be imported from collections.abc |
|
Yes |
|
— |
Any |
Yes |
|
Don’t use |
Any |
Yes |
|
Do not use printf style formatting or .format(). Use f-string instead to be more readable and efficient. |
Any |
Yes |
|
Comparisons to singleton primitives should not be done with == or !=, as they check equality rather than identity. Use |
Any |
Yes |
|
— |
Any |
Yes |