Skip to main content

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_dirs
  • ignored_filetypes
  • whitelisted_unicode_chars
  • common_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

unicode_detector-0.1.1.tar.gz (21.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

unicode_detector-0.1.1-py3-none-any.whl (21.4 kB view details)

Uploaded Python 3

File details

Details for the file unicode_detector-0.1.1.tar.gz.

File metadata

  • Download URL: unicode_detector-0.1.1.tar.gz
  • Upload date:
  • Size: 21.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for unicode_detector-0.1.1.tar.gz
Algorithm Hash digest
SHA256 919f58f57c11d3e6c1ab8174881733967d0cd7404ab569a01f7c9f8c693246c2
MD5 43c29437654f922c26e2b1d8bec3bc6f
BLAKE2b-256 36edaab7b10d00193b4c40c79f8a145d03b00cbcbb8816df346a4f58650ca621

See more details on using hashes here.

Provenance

The following attestation bundles were made for unicode_detector-0.1.1.tar.gz:

Publisher: publish.yaml on felix314159/unicode-detector

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file unicode_detector-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for unicode_detector-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6f793425b0e3f7e6bd76137b2a07373cb06ce0701f47473aacc6d5772ad7c455
MD5 e19109172c5ddd4a5ed1213259ebccc2
BLAKE2b-256 07937085db7763f199d124953dd01bce8f352d7f88558ae10e0e3feceeb38bb0

See more details on using hashes here.

Provenance

The following attestation bundles were made for unicode_detector-0.1.1-py3-none-any.whl:

Publisher: publish.yaml on felix314159/unicode-detector

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page