Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
A Flake8 plugin to checking module level docstrings, future-imports, and dunders as specified in PEP 8
A Flake8 plugin to enforce code quality by checking module level docstrings, future-imports, and module level dunders as specified in PEP 8
You can install this plugin via pip:
pip install module-level-lint
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
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
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
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
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
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)
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
Contributions, issues, and feature requests are welcome! Please feel free to submit a pull request or open an issue.
This plugin is licensed under the MIT License.
FAQs
A Flake8 plugin to checking module level docstrings, future-imports, and dunders as specified in PEP 8
We found that module-level-lint demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.