Constants

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: typing_extensions.Final = frozenset({'__import__', 'breakpoint', 'compile', 'copyright', 'credits', 'delattr', 'dir', 'eval', 'exec', 'exit', 'globals', 'hasattr', 'help', 'input', 'locals', 'pprint', 'pprint.pprint', 'print', 'quit', 'reveal_type', 'staticmethod', 'vars'})

List of functions we forbid to use.

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

List of module metadata we forbid to use.

VARIABLE_NAMES_BLACKLIST: typing_extensions.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: typing_extensions.Final = frozenset({'0O', '1I', '1l', 'O0'})

List of characters sequences that are hard to read.

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

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

ALL_MAGIC_METHODS: typing_extensions.Final = 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: typing_extensions.Final = frozenset({'__del__', '__delattr__', '__delete__', '__delitem__', '__dir__', '__reduce__', '__reduce_ex__'})

List of magic methods that are forbidden to use.

YIELD_MAGIC_METHODS_BLACKLIST: typing_extensions.Final = frozenset({'__abs__', '__add__', '__aenter__', '__aexit__', '__aiter__', '__and__', '__anext__', '__await__', '__bool__', '__bytes__', '__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: typing_extensions.Final = frozenset({'__abs__', '__add__', '__aiter__', '__and__', '__await__', '__bool__', '__bytes__', '__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.

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

List of builtin classes that are allowed to subclass.

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

List of nested functions’ names we allow to use.

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

List of allowed __future__ imports.

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

List of blacklisted module names.

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

List of allowed module magic names.

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

List of bad magic module functions.

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

Regex pattern to name modules.

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

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

MAX_NO_COVER_COMMENTS: typing_extensions.Final = 5

Maximum amount of pragma no-cover comments per module.

MAX_LEN_YIELD_TUPLE: typing_extensions.Final = 5

Maximum length of yield tuple expressions.

MAX_COMPARES: typing_extensions.Final = 2

Maximum number of compare nodes in a single expression.

MAX_CONDITIONS: typing_extensions.Final = 4

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

MAX_ELIFS: typing_extensions.Final = 3

Maximum number of elif blocks in a single if condition:

MAX_EXCEPT_CASES: typing_extensions.Final = 3

Maximum number of except cases in a single try clause.

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

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

VAGUE_IMPORTS_BLACKLIST: typing_extensions.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: typing_extensions.Final = frozenset({'bool', 'bytes', 'complex', 'float', 'int', 'str'})

List of literals without arguments we forbid to use.

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

List of functions in which arguments must be tuples.

ALLOWED_NESTED_IMPORTS_CONDITIONS: typing_extensions.Final = frozenset({'TYPE_CHECKING'})

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

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

List of commonly used aliases