Skip to main content

ASCII and character policy checks for text files

Project description

asciilint

PyPI version Python versions CI tests Mypy check Ruff check Documentation License

Minimal, configurable, CI-friendly character policy checks for text files.

By default, asciilint recursively scans a project and fails when UTF-8 text files contain non-ASCII characters. It can also enforce arbitrary Unicode allowlists and denylists, so it is useful for broader character policy checks.

Installation

Install asciilint from PyPI:

pip install asciilint

For an isolated, global CLI installation, use pipx:

pipx install asciilint

To run it once without adding it to your environment, use uvx:

uvx asciilint --help

Usage

asciilint .

Example failing output:

> Checking characters in /path/to/project
Files found: 3, 2 to scan, 1 ignored
Checking text:
✓x
Files checked: 2 text, 0 binary skipped, 0 read error(s)

Issues :-(
> Disallowed characters
  1. docs/page.md
     1. [L012:C018] U+2014 "\u2014" not allowed by policy
Summary: 1 disallowed character(s), 0 read error(s)

Exit code 0 means no issues. Exit code 1 means disallowed characters or read errors were found.

Configuration

Create asciilint.toml:

[asciilint]
paths = ["."]
respect_gitignore = true
ignore_files = [".asciilintignore"]
allowed_ranges = ["U+0000-U+007F"]
allowed_chars = []
disallowed_ranges = []
disallowed_chars = []
max_issues_per_file = 5

Ignore files use gitignore syntax and are matched with pathspec. .gitignore is respected by default. You can add other ignore files, for example:

asciilint . --ignore-file .asciilintignore --ignore-file config/lint.ignore

Character ranges can be written as U+0000-U+007F, 0x20..0x7e, 32-126, or single code points such as U+00A9. Deny rules take precedence over allow rules.

To allow any Unicode character except a small denylist:

asciilint . --allow-any --disallowed-char "→" --disallowed-range U+2000-U+206F

UTF-8 and binary files

asciilint assumes text files are UTF-8. Files that are classified as text but cannot be decoded as UTF-8 are reported explicitly and skipped. Binary files are skipped automatically using the zlib txtvsbin heuristic.

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

asciilint-0.2.0.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

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

asciilint-0.2.0-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

Details for the file asciilint-0.2.0.tar.gz.

File metadata

  • Download URL: asciilint-0.2.0.tar.gz
  • Upload date:
  • Size: 14.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for asciilint-0.2.0.tar.gz
Algorithm Hash digest
SHA256 8d3903d6de92a58ed93e4391467db3e6d5347b966935e1934059c83b6d40a58a
MD5 c8d6bf00630823c04d8a8480cf15af0f
BLAKE2b-256 e160edae851c9dbdccab6dd88922b4b17452588166dae318b27a92e61991954e

See more details on using hashes here.

File details

Details for the file asciilint-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: asciilint-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 13.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for asciilint-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ad3f22347deb344adcff4f7f2aaf461ecd12a408a6c14d7c7349c37f7daad3c1
MD5 d2564283fbeea6a9aa08bb7676bdd4cc
BLAKE2b-256 36235fe8ad973ce8140a9fa60d0b0012acf7482a8f2c3a815297960e6a882b28

See more details on using hashes here.

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