Skip to main content

A flake8 plugin to ban PEP-420 implicit namespace packages.

Project description pre-commit

A flake8 plugin to ban PEP-420 implicit namespace packages.


Python 3.6 to 3.10 supported.


First, install with pip:

python -m pip install flake8-no-pep420

Second, check that flake8 lists the plugin in its version line:

$ flake8 --version
3.8.4 (flake8-no-pep420: 1.0.0, mccabe: 0.6.1, pycodestyle: 2.5.0, pyflakes: 2.1.1) CPython 3.8.0 on Darwin

Third, add the INP prefix to your select list. For example, if you have your configuration in setup.cfg:

select = E,F,W,INP

Linting a Django project? Check out my book Speed Up Your Django Tests which covers loads of best practices so you can write faster, more accurate tests.


Implicit namespace packages are directories of Python files without an They’re valid and importable, but unfortunately they’re silently ignored by many tools, like:

Such silent failure leads to a false sense of security:

  • Tests may look legitimate but never run
  • Code may be untested but not affect coverage statistics
  • Types may never be checked

PEP-420’s algorithm is non-trivial which is probably why such tools haven’t (yet) implemented it.


INP001: File is part of an implicit namespace package.

flake8-no-pep420 will trigger this on the first line of any file that sits in a directory without a file.

Often projects have a few root files not in packages, for which an file should not be added. For example, Django projects normally have a file in the root of their repository. In these cases you can ignore the INP001 error. It’s possible to use # noqa: INP001 to ignore the error in-line, but this isn’t possible if the first line is a shebang, such as in Django’s As such, it’s preferable to use Flake8’s per-file-ignores option, for example in setup.cfg:

# ...
per-file-ignores =

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for flake8-no-pep420, version 2.0.0
Filename, size File type Python version Upload date Hashes
Filename, size flake8_no_pep420-2.0.0-py3-none-any.whl (4.8 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size flake8-no-pep420-2.0.0.tar.gz (5.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page