Skip to main content

A pre-commit hook, that enforces ASCII content.

Project description

Enforce ASCII

pre-commit

A Python package to find files containing non-ASCII encoded characters. If you find any bugs, issues or anything, please use the issue tracker on GitHub - issues and PRs are welcome ❤️

Install

It's on [PyPi] as ski-lint, you can install it with pip, pipx, etc.

pip install ski-lint

Usage

$ ski-lint --help
usage: ski-lint [-h] [--version] [--check] [-w CONTEXT_WIDTH] [-c CONFIG_FILE] FILENAME [FILENAME ...]

A pre-commit hook, that rejects files containing non-ASCII characters.

positional arguments:
  FILENAME              path to the files to check

options:
  -h, --help            show this help message and exit
  --version             show program's version number and exit
  --check               return code is `1`, when non-ASCII files are found
  -w, --context-width CONTEXT_WIDTH
                        width of the context of the non-ASCII line
  -c, --config-file CONFIG_FILE
                        path to config file

CONFIG_FILE is an optional yaml file (default .ski-lint.yml) in which you can override any CLI argument or add additional configuration:

accepted_values:
    - U+E4
    - U+2026
context_width: 50

Example

$ ski-lint tests/files/*/*.txt
2024-10-03 16:24:50,339 - ERROR - tests/files/bad/special.txt (Windows-1252), line 1, pos 9, char U+2026 '…', context: 'Hi there…'
2024-10-03 16:24:50,339 - ERROR - tests/files/bad/umlaut.txt (utf-8), line 1, pos 349, char U+E4 'ä', context: 'y next level pitchfork käle chips leggings gastrop'
2024-10-03 16:24:50,339 - ERROR - tests/files/bad/umlaut.txt (utf-8), line 1, pos 547, char U+F6 'ö', context: 'gs. Waistcoat jianbing föur dollar toast jean shor'
2024-10-03 16:24:50,339 - ERROR - tests/files/bad/umlaut.txt (utf-8), line 3, pos 190, char U+C5 'Å', context: 'eitan viral photo booth Åir plant cliche neutra la'
2024-10-03 16:24:50,339 - ERROR - tests/files/bad/zero-width-space.txt (Windows-1252), line 1, pos 62, non-printable char U+200B, context: 'ace (U+200B) at the end!U+200B'

Pre-Commit

This can be used as a pre-commit hook:

- repo: https://github.com/svdimchenko/ski-lint
  rev: v0.1.0
  hooks:
      - id: ski-lint

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

ski_lint-0.3.0.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

ski_lint-0.3.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file ski_lint-0.3.0.tar.gz.

File metadata

  • Download URL: ski_lint-0.3.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.1 Linux/6.5.0-1025-azure

File hashes

Hashes for ski_lint-0.3.0.tar.gz
Algorithm Hash digest
SHA256 89859ffb67bdf972c959cecee4a2120e7736eab9a2f2cfc6e5706e216f500d39
MD5 31c5297b24eec61b63955c9465201407
BLAKE2b-256 9587969f0a2ab631cd5c59c37f6e5c8a88eea6a4b6df00acfb8b1262403f5066

See more details on using hashes here.

File details

Details for the file ski_lint-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: ski_lint-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.1 Linux/6.5.0-1025-azure

File hashes

Hashes for ski_lint-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7a32d7dc35ef04647581c8c0c2d96fb6e0e14588b8fc090569796380b168ba0c
MD5 ba9ce966e57f18110c1ccd58be5e80f7
BLAKE2b-256 0511b207f1094475a7694d1961ad85d5c7281c8123416d547d67d7edaba2742a

See more details on using hashes here.

Supported by

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