Detect non-whitelisted Unicode characters in text files
Project description
unicode-detector
unicode-detector is a small Python CLI for finding non-whitelisted Unicode
characters in text files. It is designed to work well in local development,
CI, and GitHub Actions workflows that only scan changed files.
Install
Use it directly with uvx once it is published:
uvx unicode-detector --help
For local development in this repo:
uv run unicode-detector --help
Usage
Scan the current directory recursively:
uv run unicode-detector
Scan a single file or directory:
uv run unicode-detector path/to/file.py
uv run unicode-detector path/to/directory
Scan only changed files from a newline-delimited list:
uv run unicode-detector --files-from changed_files.txt
Scan files piped from standard input:
git diff --name-only --diff-filter=AMR HEAD~1 HEAD | \
uv run unicode-detector --files-from -
Emit machine-readable JSON:
uv run unicode-detector --format json
Configuration
By default the CLI searches upward for the nearest pyproject.toml and reads
[tool.unicode-detector].
You can also point it at a dedicated TOML file:
uv run unicode-detector --config unicode-detector.toml
Supported config keys:
ignored_dirsignored_filetypeswhitelisted_unicode_charscommon_unicode_threshold
Example pyproject.toml:
[tool.unicode-detector]
ignored_dirs = [".git", ".venv", "node_modules"]
ignored_filetypes = [".png", ".svg"]
whitelisted_unicode_chars = ["→", "✓", "║"]
common_unicode_threshold = 5
See examples/pyproject.toml for a copy-pasteable example.
GitHub Actions
Minimal workflow for another repository
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v7
- name: Collect changed files
run: git diff --name-only --diff-filter=AMR "$BASE_SHA" "$HEAD_SHA" > changed_files.txt
- name: Run unicode-detector
run: uvx unicode-detector --files-from changed_files.txt
This repository's PR workflow
This repo includes
.github/workflows/unicode-detector.yaml,
which scans the full current PR diff on pull_request opened,
reopened, and synchronize.
Release process
- Bump
unicode_detector.__version__ - Update CHANGELOG.md
- Create a Git tag such as
v0.1.0 - Push the tag to trigger the PyPI publish workflow
Development
Run local checks with:
uv run ruff check .
uv run mypy
uv run pytest
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
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 unicode_detector-0.1.0.tar.gz.
File metadata
- Download URL: unicode_detector-0.1.0.tar.gz
- Upload date:
- Size: 21.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
722477ab3629a47d427074f7a1783365d49fcd40ae1d2f204f1525ab789f7f67
|
|
| MD5 |
5ca439baf84501c54fbb517d5937afc8
|
|
| BLAKE2b-256 |
e4303b4a0178cb200052ab035a236ae23ab06b2789ad7ec8211500e4c67e78c7
|
Provenance
The following attestation bundles were made for unicode_detector-0.1.0.tar.gz:
Publisher:
publish.yaml on felix314159/unicode-detector
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
unicode_detector-0.1.0.tar.gz -
Subject digest:
722477ab3629a47d427074f7a1783365d49fcd40ae1d2f204f1525ab789f7f67 - Sigstore transparency entry: 1160327965
- Sigstore integration time:
-
Permalink:
felix314159/unicode-detector@00000006e05cf9c78208fa6a39f93d80f1327547 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/felix314159
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@00000006e05cf9c78208fa6a39f93d80f1327547 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file unicode_detector-0.1.0-py3-none-any.whl.
File metadata
- Download URL: unicode_detector-0.1.0-py3-none-any.whl
- Upload date:
- Size: 21.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
69fb8d015ed44ffdd73c7723f913b208041989e29216444ae8782218d01aa42e
|
|
| MD5 |
b109484ec8b4524da2221b477fa584ca
|
|
| BLAKE2b-256 |
0a445cce6baefce81bd261f559b4bd2eac8772556b6bf501616bcdf7b54cc3b5
|
Provenance
The following attestation bundles were made for unicode_detector-0.1.0-py3-none-any.whl:
Publisher:
publish.yaml on felix314159/unicode-detector
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
unicode_detector-0.1.0-py3-none-any.whl -
Subject digest:
69fb8d015ed44ffdd73c7723f913b208041989e29216444ae8782218d01aa42e - Sigstore transparency entry: 1160328050
- Sigstore integration time:
-
Permalink:
felix314159/unicode-detector@00000006e05cf9c78208fa6a39f93d80f1327547 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/felix314159
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@00000006e05cf9c78208fa6a39f93d80f1327547 -
Trigger Event:
workflow_dispatch
-
Statement type: