pythonimportlintpyflakes

How to ignore Pyflakes errors ‘imported but unused’ in ‘__init__.py’ files?


I split my tests across multiple Python files:

tests
├── __init__.py
├── test_apples.py
└── test_bananas.py.py

I import the tests in the ‘__init__.py’ file:

from test_apples import ApplesTest
from test_bananas import BananasTest

However running Pyflakes on the command-line:

pyflakes .

outputs the following errors:

tests/__init__.py:1: [E] PYFLAKES:'ApplesTest' imported but unused
tests/__init__.py:2: [E] PYFLAKES:'BananasTest' imported but unused

Solution

  • Add # pyflakes.ignore comment on every line you want to ignore (in your case import statements).