Constants

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

It contains lists of keywords and built-in functions we discourage to use. It also contains some exceptions that we allow to use in our codebase.

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

List of functions we forbid to use.

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

List of module metadata we forbid to use.

VARIABLE_NAMES_BLACKLIST = 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.

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

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

ALL_MAGIC_METHODS = frozenset({'__abs__', '__add__', '__aenter__', '__aexit__', '__aiter__', '__and__', '__anext__', '__await__', '__bool__', '__bytes__', '__call__', '__ceil__', '__class_getitem__', '__complex__', '__contains__', '__del__', '__delattr__', '__delete__', '__delitem__', '__dir__', '__divmod__', '__enter__', '__eq__', '__exit__', '__float__', '__floor__', '__floordiv__', '__format__', '__ge__', '__get__', '__getattr__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__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__', '__lshift__', '__lt__', '__matmul__', '__missing__', '__mod__', '__mul__', '__ne__', '__neg__', '__new__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__', '__rdivmod__', '__repr__', '__reversed__', '__rfloordiv__', '__rlshift__', '__rmatmul__', '__rmod__', '__rmul__', '__ror__', '__round__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__set__', '__set_name__', '__setattr__', '__setitem__', '__str__', '__sub__', '__subclasscheck__', '__truediv__', '__trunc__', '__xor__'})

List of all magic methods from the python docs.

MAGIC_METHODS_BLACKLIST = frozenset({'__del__', '__delattr__', '__delete__', '__delitem__', '__dir__'})

List of magic methods that are forbidden to use.

YIELD_MAGIC_METHODS_BLACKLIST = frozenset({'__abs__', '__add__', '__aenter__', '__aexit__', '__aiter__', '__and__', '__anext__', '__await__', '__bool__', '__bytes__', '__call__', '__ceil__', '__class_getitem__', '__complex__', '__contains__', '__del__', '__delattr__', '__delete__', '__delitem__', '__dir__', '__divmod__', '__enter__', '__eq__', '__exit__', '__float__', '__floor__', '__floordiv__', '__format__', '__ge__', '__get__', '__getattr__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__iadd__', '__iand__', '__ifloordiv__', '__ilshift__', '__imatmul__', '__imod__', '__imul__', '__index__', '__init__', '__init_subclass__', '__instancecheck__', '__int__', '__invert__', '__ior__', '__ipow__', '__irshift__', '__isub__', '__itruediv__', '__ixor__', '__le__', '__len__', '__length_hint__', '__lshift__', '__lt__', '__matmul__', '__missing__', '__mod__', '__mul__', '__ne__', '__neg__', '__new__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__', '__rdivmod__', '__repr__', '__reversed__', '__rfloordiv__', '__rlshift__', '__rmatmul__', '__rmod__', '__rmul__', '__ror__', '__round__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__set__', '__set_name__', '__setattr__', '__setitem__', '__str__', '__sub__', '__subclasscheck__', '__truediv__', '__trunc__', '__xor__'})

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

ASYNC_MAGIC_METHODS_BLACKLIST = frozenset({'__abs__', '__add__', '__aiter__', '__and__', '__await__', '__bool__', '__bytes__', '__call__', '__ceil__', '__class_getitem__', '__complex__', '__contains__', '__del__', '__delattr__', '__delete__', '__delitem__', '__dir__', '__divmod__', '__enter__', '__eq__', '__exit__', '__float__', '__floor__', '__floordiv__', '__format__', '__ge__', '__get__', '__getattr__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__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__', '__lshift__', '__lt__', '__matmul__', '__missing__', '__mod__', '__mul__', '__ne__', '__neg__', '__new__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__', '__rdivmod__', '__repr__', '__reversed__', '__rfloordiv__', '__rlshift__', '__rmatmul__', '__rmod__', '__rmul__', '__ror__', '__round__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__set__', '__set_name__', '__setattr__', '__setitem__', '__str__', '__sub__', '__subclasscheck__', '__truediv__', '__trunc__', '__xor__'})

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

NESTED_CLASSES_WHITELIST = frozenset({'Meta', 'Params'})

List of nested classes’ names we allow to use.

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

List of builtin classes that are allowed to subclass.

NESTED_FUNCTIONS_WHITELIST = frozenset({'decorator', 'factory'})

List of nested functions’ names we allow to use.

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

List of allowed __future__ imports.

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

List of blacklisted module names.

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

List of allowed module magic names.

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

List of bad magic module functions.

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

Regex pattern to name modules.

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

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

MAX_NOQA_COMMENTS = 10

Maximum amount of noqa comments per module.

MAX_NO_COVER_COMMENTS = 5

Maximum amount of pragma no-cover comments per module.

MAX_LEN_YIELD_TUPLE = 5

Maximum length of yield tuple expressions.