PY3.C0415

Import outside toplevel

Used when an import statement is used anywhere other than the module toplevel. Move this import to the top of the file.

Noncompliant Code:

Copy
def print_python_version():
    import sys
    print(sys.version_info)

Compliant Code:

Copy
import sys
def print_python_version():
    print(sys.version_info)

The content on this page is adapted from the Pylint User Guide, Copyright ©2003-2022, Logilab, PyCQA and contributors. All rights reserved. https://pylint.pycqa.org/en/latest/index.html#, and is used under the Python Software Foundation License Version 2. Examples, recipes, and other code in the Pylint documentation are additionally licensed under the Zero Clause BSD License.