Skip to content

constant-imported-as-non-constant (N811)#

Derived from the pep8-naming linter.

What it does#

Checks for constant imports that are aliased to non-constant-style names.

Why is this bad?#

PEP 8 recommends naming conventions for classes, functions, constants, and more. The use of inconsistent naming styles between import and alias names may lead readers to expect an import to be of another type (e.g., confuse a Python class with a constant).

Import aliases should thus follow the same naming style as the member being imported.


from example import CONSTANT_VALUE as ConstantValue

Use instead:

from example import CONSTANT_VALUE