Flake8 plugin to detect non-English comments and string literals
Project description
flake8-only-english
⭐️ Thanks everyone who has starred the project, it means a lot!
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.
Features
- 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.
Installation
pip install flake8-only-english
Usage
Run normally via flake8:
flake8 app
flake8 --select=NLE
flake8 --select=NLE001
flake8 --select=NLE002
Example output:
/example.py:5:10: NLE001 Non-English text in docstring
Example
# This is a valid English comment
def hello():
"""Valid English docstring"""
msg = "Hello world"
return msg
Example (with pre-commit)
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
Error Codes
- NLE001 — Non-English text in docstring.
- NLE002 — Non-English text in string literal
Development
Clone and install in editable mode:
git clone https://github.com/AlgorithmAlchemy/flake8-only-english
cd flake8-only-english
pip install -e .[dev]
pytest
License
MIT License © 2025 AlgorithmAlchemy
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flake8_only_english-0.3.3.tar.gz.
File metadata
- Download URL: flake8_only_english-0.3.3.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
153ef8165835421cdaae97b30ab67cd46bc26ec1e19ba61e5e76986d05458380
|
|
| MD5 |
fc40c84c20f1e8090104f788abcee91c
|
|
| BLAKE2b-256 |
b2aae2d49021649625b1d1cc87cbb518ad29b90c515df946330d46be272362dc
|
File details
Details for the file flake8_only_english-0.3.3-py3-none-any.whl.
File metadata
- Download URL: flake8_only_english-0.3.3-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
14f3ded68ed3e8264de202fb9ff19e9a3952fb71f9f80374da9c927274fc0a00
|
|
| MD5 |
17f09b7e16f4774b81a1e76e614c2fe7
|
|
| BLAKE2b-256 |
0923e9c6a19729ec65e0b3df44f4bb2e40e4ec36efa51363e66e2ee64a011e1f
|