Skip to content

Latest commit

 

History

History
170 lines (102 loc) · 4.83 KB

categories.md

File metadata and controls

170 lines (102 loc) · 4.83 KB

Categories

Here is a list of the built-in categories in Refurb, and their meanings.

abc

These check for code relating to Abstract Base Classes.

builtin

Checks that have the builtin category cover a few different topics:

  • Built-in functions such as print(), open(), str(), and so on
  • Statements such as del
  • File system related operations such as open() and readlines()

collections

These checks are for the collections standard library module.

control-flow

These checks deal with the control flow of a program, such as optimizing usage of return and continue, removing if statements under certain conditions, and so on.

contextlib

These checks are for the contextlib standard library module.

datetime

These checks are for the datetime standard library module.

decimal

These checks are for the decimal standard library module.

dict

These checks cover:

  • Usage of dict objects
  • In some cases, objects supporting the Mapping protocol

fastapi

These are checks relating to the third-party FastAPI library.

fstring

These checks relate to Python's f-strings.

fractions

These checks are for the fractions standard library module.

functools

These checks relate to the functools standard library module.

hashlib

These checks relate to the hashlib standard library module.

iterable

These checks cover:

  • Iterable types such as list and tuple
  • Standard library objects which are commonly iterated over such as dict keys

itertools

These checks relate to the itertools standard library module.

math

These checks relate to the math standard library module.

operator

These checks relate to the operator standard library module.

logical

These checks relate to logical cleanups and optimizations, primarily in if statements, but also in boolean expressions.

list

These checks cover usage of the built-in list object.

pattern-matching

Checks related to Python 3.10's Structural Pattern Matching.

pathlib

These checks relate to the pathlib standard library module.

performance

These checks are supposted to find slow code that can be written faster. The threshold for "fast" and "slow" are somewhat arbitrary and depend on the check, but in general you should expect that a check in the performance category will make your code faster (and should never make it slower).

python39, python310, python311

These checks are only enabled for Python versions 3.9, 3.10, or 3.11 respectively, or in some way are improved in later versions of Python. For example, isinstance(x, y) or isinstance(x, z) can be written as isinstance(x, (y, z)) in any Python version, but in Python 3.10+ it can be written as isinstance(x, y | z).

pythonic

This is a general catch-all for things which are "unpythonic". It differs from the readability category because "unreadable" code can still be pythonic.

readability

These checks aim to make existing code more readable. This can be subjective, but in general, they reduce the horizontal or vertical length of your code, or make the underlying meaning of the code more apparent.

regex

These checks are for the re standard library module.

scoping

These checks have to do with Python's scoping rules. For more info on how Python's scoping rules work, read this article.

secrets

These checks are for the secrets standard library module.

set

These checks deal with usage of set objects in Python.

shlex

These checks are for the shlex standard library module.

string

These checks deal with usage of str objects in Python.

truthy

These checks cover truthy and falsy operations in Python, primarily in the context of assert and if statements.