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.0.tar.gz (21.7 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.0-py3-none-any.whl (21.3 kB view details)

Uploaded Python 3

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

Hashes for unicode_detector-0.1.0.tar.gz
Algorithm Hash digest
SHA256 722477ab3629a47d427074f7a1783365d49fcd40ae1d2f204f1525ab789f7f67
MD5 5ca439baf84501c54fbb517d5937afc8
BLAKE2b-256 e4303b4a0178cb200052ab035a236ae23ab06b2789ad7ec8211500e4c67e78c7

See more details on using hashes here.

Provenance

The following attestation bundles were made for unicode_detector-0.1.0.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.0-py3-none-any.whl.

File metadata

File hashes

Hashes for unicode_detector-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 69fb8d015ed44ffdd73c7723f913b208041989e29216444ae8782218d01aa42e
MD5 b109484ec8b4524da2221b477fa584ca
BLAKE2b-256 0a445cce6baefce81bd261f559b4bd2eac8772556b6bf501616bcdf7b54cc3b5

See more details on using hashes here.

Provenance

The following attestation bundles were made for unicode_detector-0.1.0-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