Skip to main content

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

Project description

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 MLL001,MLL002,MLL003 [path]

Features

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

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

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.

Project details


Download files

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

Source Distribution

module_level_lint-0.1.1.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

module_level_lint-0.1.1-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file module_level_lint-0.1.1.tar.gz.

File metadata

  • Download URL: module_level_lint-0.1.1.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.9.16 Linux/6.2.0-34-generic

File hashes

Hashes for module_level_lint-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e735c1cf4ff97a5dcecbe0ea0cde1c89209683681e89adfdef256715c6eba55e
MD5 f5a805bf7480c8214d98219404b02472
BLAKE2b-256 719b8a029781a94d3142366e0108928cea73faf4a285d0fea89becafd9550ccd

See more details on using hashes here.

File details

Details for the file module_level_lint-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: module_level_lint-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.9.16 Linux/6.2.0-34-generic

File hashes

Hashes for module_level_lint-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cb7527ae42ddce5868f3a4d3fb926301b8f09aea006bbba4091f6011c0363f30
MD5 7c416309c60f681c3922e356889d8d08
BLAKE2b-256 e4f7b2e14f33baabf27108c6f78c04142ddc1d530e192c43e1e7a6bf8a3a7096

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page