Skip to main content

Module Level Lint

A Flake8 plugin to enforce code quality by checking module level docstrings, future-imports, and module level dunders as specified in PEP 8

Installation

You can install this plugin via pip:

pip install module-level-lint

Usage

After installation, you can use this plugin with the flake8 command. Here's how to run it:

flake8 [path]

To show only module level lint errors, run:

flake8 --select MLL [path]

To show only specific errors

flake8 --select MLL001,MLL002 [path]

To apply formatting

flake8 --select MLL [path] --fix

Features

Lint

Module Docstring Check: Ensure that your docstrings are always at the top of the file

  • Linting Error: MLL001

Example:

import random

# Bad: Module docstring is not at the top of the file
"""This is a docstring"""

def foo():
    pass
# Good: Docstring present at the top of the file
""" This is a docstring. """

def foo():
    pass

Future-Imports Check: Ensure that future-imports are always at the top after module docstrings

  • Linting Error: MLL002

Example:

import random

# Bad: Future-imports is not at the top of the file
from __future__ import print_function
# Good: Future-imports is at the top of the file
from __future__ import division

import random
  • Linting Error: MLL003

Example:

from __future__ import print_function

# Bad: Docstring is not at the top of the file
"""This is a docstring."""
"""This is a docstring."""

# Good: Future-imports is at the top of the file after docstring
from __future__ import division

Module-Level Dunders: Ensure that module level dunders are always at the top after future-imports or docstrings

  • Linting Error: MLL004

Example:

import random

# Bad: Module level dunder after imports
__all__ = ["foo"]

def foo():
    pass
# Bad: Module level dunder before docstring
__all__ = ["foo"]

"""This is a docstring"""

def foo():
    pass
def foo():
    pass

# Bad: Module level dunder after code
__all__ = ["foo"]
# Good: Module level dunder at the top of the file
__all__ = ["foo"]

def foo():
    pass

Format

With the --fix flag, this plugin will try to format the files that have no rule violations. It will fix the newlines in the following format:

"""Docstring goes here"""   # An empty line after docstrings

from __future__ import annotations  # An empty line after future imports

__all__ = ["foo"]  # An empty line after module dunders

import random   # Rest of the code


def foo():
    return random.randint(1, 10)

Configuration

This plugin doesn't require any specific configuration, but you can include its error codes in your Flake8 configuration file to disable or enable specific checks:

[flake8]
extend-ignore = MLL001, MLL002, MLL003, MLL004

Contributing

Contributions, issues, and feature requests are welcome! Please feel free to submit a pull request or open an issue.

License

This plugin is licensed under the MIT License.

Release files for module-level-lint 0.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for module-level-lint 0.2.3
File Size Uploaded
module_level_lint-0.2.3.tar.gz 4.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for module-level-lint 0.2.3
File Interpreter ABI Platform
module_level_lint-0.2.3-py3-none-any.whl Python 3 none any Details

Total release size: 11.3 kB

Release files / module_level_lint-0.2.3.tar.gz

Download URL module_level_lint-0.2.3.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
8bf91b552a8df994a01cdfd302040e221b5727dc8735b85fc6e86a768c590f8f
BLAKE2b-256 checksum
How to use checksums
181bbbbfd4cc357e96a1cdca0748cdf5c9ee8ad2c4198d9e3f4c7ce72ae17b18
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 13, 2026.

Transparency log

Release files / module_level_lint-0.2.3-py3-none-any.whl

Download URL module_level_lint-0.2.3-py3-none-any.whl
Size 6.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
24a327cea9c44fe6091e331f6da2764bd3e8753af87dceccfa4b1789a8d582ab
BLAKE2b-256 checksum
How to use checksums
7654db7259253ab476926f4b6f2a5453a6a6014027cdebfc6ad69099ff3f4f1e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 13, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.3 This release

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page