This module contains list of white- and black-listed python members.

We add values here when we want to make them public. Or when a value is reused in several places. Then, we automatically have to add it here and document it.

Other constants that are not used across modules and does not require to be documented can be defined where they are used.

All values here must be documented with #: comments.

FUNCTIONS_BLACKLIST: Final = frozenset({'__import__', 'breakpoint', 'compile', 'copyright', 'credits', 'delattr', 'dir', 'eval', 'exec', 'exit', 'globals', 'hasattr', 'help', 'input', 'locals', 'pprint', 'pprint.pprint', 'print', 'quit', 'reveal_locals', 'reveal_type', 'staticmethod', 'vars'})

List of functions we forbid to use.

MODULE_METADATA_VARIABLES_BLACKLIST: Final = frozenset({'__about__', '__all__', '__author__', '__version__'})

List of module metadata we forbid to use.

VARIABLE_NAMES_BLACKLIST: Final = frozenset({'bar', 'baz', 'content', 'contents', 'data', 'do', 'false', 'file', 'foo', 'handle', 'handler', 'info', 'item', 'items', 'no', 'obj', 'objects', 'objs', 'param', 'parameters', 'params', 'result', 'results', 'some', 'true', 'val', 'vals', 'value', 'values', 'var', 'variable', 'vars'})

List of variable names we forbid to use.

UNREADABLE_CHARACTER_COMBINATIONS: Final = frozenset({'0O', '1I', '1l', 'O0'})

List of character sequences that are hard to read.

SPECIAL_ARGUMENT_NAMES_WHITELIST: Final = frozenset({'cls', 'mcs', 'self'})

List of special names that are used only as first argument in methods.

ALL_MAGIC_METHODS: Final = frozenset({'__abs__', '__add__', '__aenter__', '__aexit__', '__aiter__', '__and__', '__anext__', '__attrs_init__', '__attrs_post_init__', '__attrs_pre_init__', '__await__', '__bool__', '__bytes__', '__call__', '__ceil__', '__class_getitem__', '__cmp__', '__coerce__', '__complex__', '__contains__', '__copy__', '__deepcopy__', '__del__', '__delattr__', '__delete__', '__delitem__', '__dir__', '__divmod__', '__enter__', '__eq__', '__exit__', '__float__', '__floor__', '__floordiv__', '__format__', '__fspath__', '__ge__', '__get__', '__getattr__', '__getattribute__', '__getinitargs__', '__getitem__', '__getnewargs__', '__getnewargs_ex__', '__getstate__', '__gt__', '__hash__', '__hex__', '__iadd__', '__iand__', '__ifloordiv__', '__ilshift__', '__imatmul__', '__imod__', '__imul__', '__index__', '__init__', '__init_subclass__', '__instancecheck__', '__int__', '__invert__', '__ior__', '__ipow__', '__irshift__', '__isub__', '__iter__', '__itruediv__', '__ixor__', '__le__', '__len__', '__length_hint__', '__long__', '__lshift__', '__lt__', '__matmul__', '__missing__', '__mod__', '__mul__', '__ne__', '__neg__', '__new__', '__next__', '__nonzero__', '__oct__', '__or__', '__pos__', '__post_init__', '__pow__', '__radd__', '__rand__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__rfloordiv__', '__rlshift__', '__rmatmul__', '__rmod__', '__rmul__', '__ror__', '__round__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__set__', '__set_name__', '__setattr__', '__setitem__', '__setstate__', '__signature__', '__sizeof__', '__str__', '__sub__', '__subclasscheck__', '__truediv__', '__trunc__', '__unicode__', '__xor__'})

List of all magic methods from the python docs.

MAGIC_METHODS_BLACKLIST: Final = frozenset({'__del__', '__delattr__', '__delete__', '__delitem__', '__dir__', '__reduce__', '__reduce_ex__'})

List of magic methods that are forbidden to use.

YIELD_MAGIC_METHODS_BLACKLIST: Final = frozenset({'__abs__', '__add__', '__aenter__', '__aexit__', '__and__', '__anext__', '__attrs_init__', '__attrs_post_init__', '__attrs_pre_init__', '__await__', '__bool__', '__bytes__', '__ceil__', '__class_getitem__', '__cmp__', '__coerce__', '__complex__', '__contains__', '__copy__', '__deepcopy__', '__del__', '__delattr__', '__delete__', '__delitem__', '__dir__', '__divmod__', '__enter__', '__eq__', '__exit__', '__float__', '__floor__', '__floordiv__', '__format__', '__fspath__', '__ge__', '__get__', '__getattr__', '__getattribute__', '__getinitargs__', '__getitem__', '__getnewargs__', '__getnewargs_ex__', '__getstate__', '__gt__', '__hash__', '__hex__', '__iadd__', '__iand__', '__ifloordiv__', '__ilshift__', '__imatmul__', '__imod__', '__imul__', '__index__', '__init__', '__init_subclass__', '__instancecheck__', '__int__', '__invert__', '__ior__', '__ipow__', '__irshift__', '__isub__', '__itruediv__', '__ixor__', '__le__', '__len__', '__length_hint__', '__long__', '__lshift__', '__lt__', '__matmul__', '__missing__', '__mod__', '__mul__', '__ne__', '__neg__', '__new__', '__next__', '__nonzero__', '__oct__', '__or__', '__pos__', '__post_init__', '__pow__', '__radd__', '__rand__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__rfloordiv__', '__rlshift__', '__rmatmul__', '__rmod__', '__rmul__', '__ror__', '__round__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__set__', '__set_name__', '__setattr__', '__setitem__', '__setstate__', '__signature__', '__sizeof__', '__str__', '__sub__', '__subclasscheck__', '__truediv__', '__trunc__', '__unicode__', '__xor__'})

List of magic methods that are not allowed to be generators.

ASYNC_MAGIC_METHODS_BLACKLIST: Final = frozenset({'__abs__', '__add__', '__and__', '__attrs_init__', '__attrs_post_init__', '__attrs_pre_init__', '__await__', '__bool__', '__bytes__', '__ceil__', '__class_getitem__', '__cmp__', '__coerce__', '__complex__', '__contains__', '__copy__', '__deepcopy__', '__del__', '__delattr__', '__delete__', '__delitem__', '__dir__', '__divmod__', '__enter__', '__eq__', '__exit__', '__float__', '__floor__', '__floordiv__', '__format__', '__fspath__', '__ge__', '__get__', '__getattr__', '__getattribute__', '__getinitargs__', '__getitem__', '__getnewargs__', '__getnewargs_ex__', '__getstate__', '__gt__', '__hash__', '__hex__', '__iadd__', '__iand__', '__ifloordiv__', '__ilshift__', '__imatmul__', '__imod__', '__imul__', '__index__', '__init__', '__init_subclass__', '__instancecheck__', '__int__', '__invert__', '__ior__', '__ipow__', '__irshift__', '__isub__', '__iter__', '__itruediv__', '__ixor__', '__le__', '__len__', '__length_hint__', '__long__', '__lshift__', '__lt__', '__matmul__', '__missing__', '__mod__', '__mul__', '__ne__', '__neg__', '__new__', '__next__', '__nonzero__', '__oct__', '__or__', '__pos__', '__post_init__', '__pow__', '__radd__', '__rand__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__rfloordiv__', '__rlshift__', '__rmatmul__', '__rmod__', '__rmul__', '__ror__', '__round__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__set__', '__set_name__', '__setattr__', '__setitem__', '__setstate__', '__signature__', '__sizeof__', '__str__', '__sub__', '__subclasscheck__', '__truediv__', '__trunc__', '__unicode__', '__xor__'})

List of magic methods that are not allowed to be async.

ALLOWED_BUILTIN_CLASSES: Final = frozenset({'object', 'type'})

List of builtin classes that are allowed to subclass.

BUILTINS_WHITELIST: Final = frozenset({'_', 'copyright', 'credits', 'license'})

List of builtins that we allow to shadow.

NESTED_FUNCTIONS_WHITELIST: Final = frozenset({'decorator', 'factory', 'wrapper'})

List of nested functions’ names we allow to use.

FUTURE_IMPORTS_WHITELIST: Final = frozenset({'annotations', 'generator_stop'})

List of allowed __future__ imports.

MODULE_NAMES_BLACKLIST: Final = frozenset({'helpers', 'util', 'utilities', 'utils'})

List of blacklisted module names.

MAGIC_MODULE_NAMES_WHITELIST: Final = frozenset({'__init__', '__main__'})

List of allowed module magic names.

MAGIC_MODULE_NAMES_BLACKLIST: Final = frozenset({'__dir__', '__getattr__'})

List of bad magic module functions.

MODULE_NAME_PATTERN: Final = re.compile('^_?_?[a-z][a-z\\d_]*[a-z\\d](__)?$')

Regex pattern to name modules.

MAGIC_NUMBERS_WHITELIST: Final = frozenset({0, 0.1, 0.5, 1.0, 100, 1000, 1024, 1j, 24, 60})

Common numbers that are allowed to be used without being called “magic”.


Maximum amount of pragma no-cover comments per module.


Maximum length of yield or return tuple expressions.


Maximum number of compare nodes in a single expression.


Maximum number of conditions in a single if or while statement.

MAX_ELIFS: Final = 3

Maximum number of elif blocks in a single if condition:


Maximum number of except cases in a single try clause.

MATH_APPROXIMATE_CONSTANTS: Final = frozenset({2.718281828459045, 3.141592653589793, 6.283185307179586})

Approximate constants which real values should be imported from math module.

VAGUE_IMPORTS_BLACKLIST: Final = frozenset({'dump', 'dump_all', 'dumps', 'load', 'load_all', 'loads', 'parse', 'read', 'safe_dump', 'safe_dump_all', 'safe_load', 'safe_load_all', 'write'})

List of vague method names that may cause confusion if imported as is:

LITERALS_BLACKLIST: Final = frozenset({'bool', 'bytes', 'complex', 'float', 'int', 'str'})

List of literals without arguments we forbid to use.

TUPLE_ARGUMENTS_METHODS: Final = frozenset({'frozenset'})

List of functions in which arguments must be tuples.


Conditions that can appear in the if statement to allow nested imports.

ALIAS_NAMES_WHITELIST: Final = frozenset({'cv', 'df', 'np', 'pd', 'plt', 'sns', 'tf'})

List of commonly used aliases