Skip to main content

matra

Find code that breaks text written in Indian scripts.

Most text code is written and tested in English. Run it on Hindi, Bengali, Tamil or any of India's scripts and it fails quietly: words fall apart, real names are rejected, and truncated text ends in half a syllable. The cause is almost always the same. Indian scripts write vowels as combining marks (matras) attached to consonants, and ASCII-minded code does not count those marks as letters.

matra finds that code in JavaScript/TypeScript, Python, Go and Rust, shows the word it breaks, and gives the fix. matra fuzz then proves it by running your own functions on real words in 11 scripts.

$ matra demo
What ASCII-minded Python does to Indian-script text:

  re.findall(r'\w+', 'हिंदी')                -> ['ह', 'द']
  'हिंदी'.isalpha()                         -> False
  re.fullmatch(r'[A-Za-z ]+', 'प्रिया')        -> None
  'क्षमा'[:2]                               -> 'क्'
  'हिंदी'[::-1]                             -> 'ीदंिह'

None of these is exotic. 'हिंदी'.isalpha() is False, and so is isalpha() for every word with a vowel sign in Tamil, Bengali, Telugu, Punjabi and the rest. So a name check built on it rejects every name written in an Indian script. In JavaScript, /\w+/u matches nothing at all in 'हिंदी', and \b finds no word boundary in 'தமிழ்'.

Install

pip install git+https://github.com/RaktimChandra/matra-lint

Use

matra check .                       # scan a project
matra check src --min-confidence medium
matra check . --format sarif > matra.sarif   # GitHub code scanning
matra rules                         # every rule with its evidence
matra fuzz myapp.text:truncate --kind truncate

check exits with 1 when it finds something, so it can gate CI. Silence a line with # matra: ignore or // matra: ignore[MAT006], or a whole file (fixtures, test data) with matra: ignore-file in its first 10 lines.

Rules

Every rule's evidence is checked by the test suite against the real runtime, not assumed.

Rule Languages Confidence Flags Breaks because
MAT001 ascii-word-class JS/TS, Python, Go medium \w, \b in a regex re.findall(r'\w+', 'हिंदी') == ['ह', 'द']; in JS /\w+/u finds nothing
MAT002 letters-without-marks all high [\p{L}...]+ with no \p{M} 'हिंदी'.match(/[\p{L}]+/gu) gives ['ह', 'द']
MAT003 isalpha-rejects-indic Python high .isalpha(), .isalnum() False for every word with a vowel sign
MAT004 go-isletter-without-ismark Go medium unicode.IsLetter with no IsMark in the file vowel signs are category M, not L
MAT005 ascii-only-name-pattern all medium [A-Za-z] on a name, city or address rejects प्रिया
MAT006 truncation-splits-syllables all low title.slice(0, n), text[:n], &name[..n] 'क्षमा'[:2] == 'क्'; in Rust a byte cut can panic
MAT007 per-character-reversal all low s[::-1], .split('').reverse() 'हिंदी'[::-1] starts with an orphan vowel sign

Rust's \w already includes marks, so MAT001 skips Rust.

Fuzz your own functions

Static rules can only guess. The fuzz checks run your function on real words and report exactly which word broke:

from matra.fuzz import check_truncate, check_tokenize, check_validator

check_truncate(my_truncate)     # my_truncate(text, n) -> str: must end on a grapheme boundary
check_tokenize(my_tokenize)     # my_tokenize(text) -> list[str]: must keep words whole
check_validator(is_valid_name)  # is_valid_name(name) -> bool: must accept real names

Grapheme boundaries come from Unicode's own rules (UAX #29, including the conjunct rules added in Unicode 15.1), via the regex module.

In CI

- uses: RaktimChandra/matra-lint@main
  with:
    min-confidence: medium   # findings also appear in the Security tab

Found in the wild

  • A hotel-booking app's validate_name used ^[A-Za-z]+...$. matra fuzz --kind validate showed it rejected all 9 real names in 9 scripts (राकेश, முருகன், সৌরভ, ...).
  • Clipy #982: a transcript grouper used char::is_alphanumeric, which counts vowel signs as letters, so a lone ि token after a pause split कि into two segments.

Limits

This is a line-based scanner, not a type checker. It cannot know whether a given title[:40] ever sees Indian-script text, which is why truncation and reversal are marked low confidence. Use --min-confidence medium for a quieter first run.

License

MIT

Metadata

Release files for matra-lint 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for matra-lint 0.1.0
File Size Uploaded Provenance Actions
matra_lint-0.1.0.tar.gz 15.1 kB With provenance Details for matra_lint-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for matra-lint 0.1.0
File Interpreter ABI Platform Actions
matra_lint-0.1.0-py3-none-any.whl Python 3 none any Details for matra_lint-0.1.0-py3-none-any.whl

Total release size: 29.7 kB

Release files / matra_lint-0.1.0.tar.gz

Download URL matra_lint-0.1.0.tar.gz
Size 15.1 kB
Tags Source
SHA-256 checksum
How to use checksums
fdd7b5404f65364a004316f4cfcf7b01fb98cbc84363a63cfb11e91d1b876663
BLAKE2b-256 checksum
How to use checksums
2bcc8235ee8601aaa42805ce0311896c4dbdeb8d68acdd7f891f3b92a20db75d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.

Transparency log

Release files / matra_lint-0.1.0-py3-none-any.whl

Download URL matra_lint-0.1.0-py3-none-any.whl
Size 14.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5667f21285409e480c06cd052b87ec698817e6b58c615d5cfec60d34693d3ad8
BLAKE2b-256 checksum
How to use checksums
e4f5ce2c6f7b11104d5b78e851ef4a384f84403bd412e91cdba63a00f6f619e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.

Transparency log

Security for matra-lint 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for matra_lint-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page