Install from PyPI by clicking the badge above
View the source code on GitHub
Flake8 plugin that enforces corporate code style by detecting and reporting any only-english text in Python source
code.
It ensures that comments, docstrings, and string literals are written in English only, maintaining consistency across
the codebase.
- Scans Python files for only-english characters in:
- Comments (
# ...) - Docstrings (
""" ... """/''' ... ''') - String literals (
"..."/'...')
- Comments (
- Raises a linting error (
NL001) when only-english text is found. - Works seamlessly with Flake8 and pre-commit hooks.
- Lightweight and dependency-minimal.
pip install flake8-only-englishRun normally via flake8:
flake8 appflake8 --select=NLEflake8 --select=NLE001flake8 --select=NLE002Example output:
/example.py:5:10: NL001 only-english text detected in comment or string
# This is a valid English comment
def hello():
"""Valid English docstring"""
msg = "Hello world"
return msgIf only-english text is introduced, it will be flagged:
# Comment with only-english text #
def hello():
"""Function description with only-english text""" #
msg = "String with only-english text" #
return "Hello" Add to .pre-commit-config.yaml:
repos:
- repo: https://github.com/AlgorithmAlchemy/flake8-only-english
rev: v0.1.0
hooks:
- id: flake8
additional_dependencies: [ flake8-only-english ]Run:
pre-commit run --all-files- NL001 — only-english text detected in comment, docstring, or string literal.
Clone and install in editable mode:
git clone https://github.com/AlgorithmAlchemy/flake8-only-english
cd flake8-only-english
pip install -e .[dev]
pytestMIT License © 2025 AlgorithmAlchemy