https://github.com/algorithmalchemy/flake8-only-english
https://github.com/algorithmalchemy/flake8-only-english
ascii-comments english-comments-strings flake8-english-checker flake8-english-linter flake8-english-only lang-enforcer
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/algorithmalchemy/flake8-only-english
- Owner: AlgorithmAlchemy
- License: other
- Created: 2025-09-23T15:38:02.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2025-09-30T00:54:21.000Z (3 months ago)
- Last Synced: 2025-09-30T02:32:29.964Z (3 months ago)
- Topics: ascii-comments, english-comments-strings, flake8-english-checker, flake8-english-linter, flake8-english-only, lang-enforcer
- Language: Python
- Homepage:
- Size: 29.3 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# flake8-only-english
`⭐️ Thanks everyone who has starred the project, it means a lot!`
[](https://pypi.org/project/flake8-only-english/)
Install from **PyPI** by clicking the badge above
[](https://github.com/AlgorithmAlchemy/flake8-only-english)
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 (`"..."` / `'...'`)
* Raises a linting error (`NL001`) when only-english text is found.
* Works seamlessly with **Flake8** and **pre-commit hooks**.
* Lightweight and dependency-minimal.
---
## Installation
```bash
pip install flake8-only-english
````
---
## Usage
Run normally via `flake8`:
```bash
flake8 app
```
```bash
flake8 --select=NLE
```
```bash
flake8 --select=NLE001
```
```bash
flake8 --select=NLE002
```
Example output:
```
/example.py:5:10: NLE001 Non-English text in docstring
```
---
## Example
```python
# 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`:
```yaml
repos:
- repo: https://github.com/AlgorithmAlchemy/flake8-only-english
rev: v0.3.3
hooks:
- id: flake8
additional_dependencies: [ flake8-only-english ]
```
Run:
```bash
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:
```bash
git clone https://github.com/AlgorithmAlchemy/flake8-only-english
cd flake8-only-english
pip install -e .[dev]
pytest
```
---
## License
MIT License © 2025 [AlgorithmAlchemy](https://github.com/AlgorithmAlchemy)