.. _import-outside-toplevel:

import-outside-toplevel / C0415
===============================

**Message emitted:**

Import outside toplevel (%s)

**Description:**

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

**Problematic code:**

.. literalinclude:: /data/messages/i/import-outside-toplevel/bad.py
   :language: python

**Correct code:**

.. literalinclude:: /data/messages/i/import-outside-toplevel/good.py
   :language: python



Created by the `imports <https://github.com/PyCQA/pylint/blob/main/pylint/checkers/imports.py>`__ checker.