Skip to main content

Validate OEIS draft entries against the internal format specification and style sheet

Project description

oeis-validator

Validate OEIS entries against the internal format specification and style sheet. Parses .txt files in OEIS internal format and checks all 19 field tags for compliance, consistency, and style adherence.

PyPI Python Coverage Ruff Tests

Features

  • All 19 field tags%I, %S, %N, %C, %D, %F, %H, %I, %K, %L, %M, %N, %O, %P, %R, %S, %T, %U, %Y
  • 30 keyword checks — validates %K against the official keyword list
  • 14 style patterns — catches common OEIS style-sheet violations: counts the number of, greater or equal, less or equal, couples of, respectfully, triplets of, amount of, fulfills, allows to, except (missing for), unique vs distinct, its vs it's, p(n) ambiguity, be integer (missing article)
  • Non-ASCII detection — rejects stray Unicode in data/keyword fields
  • Reference cross-checks — URLs in %D, duplicate A-numbers in %Y, b-file ordering in %H, a_n/a[n] notation in %F
  • Program validation — missing language labels in %o, unsigned programs
  • CLI modes — file input, stdin, --demo, --coverage
  • Adversarial resilience — null bytes, BOM, mixed line endings, RTL overrides, shell injection attempts, binary input, 50-entry bulk parsing
  • Zero dependencies — pure Python stdlib

Install

pip install oeis-validator

Usage

# Validate a file
oeis-validator entry.txt

# Validate from stdin
echo '%I A000001 %S A000001 1,1,2,3,5' | oeis-validator

# Run built-in demos (good entry, bad entry, multi-entry)
oeis-validator --demo

# Show rule coverage table
oeis-validator --coverage

API

from oeis_validator import parse_entry, validate, report

entry = parse_entry(text)
issues = validate(entry)
exit_code = report(entry, issues)

Real-world validation

The data/ directory contains 10 real OEIS sequences fetched from the OEIS server. The validator produces 0 ERROR-level issues on all of them. Each warning is cross-checked against the official style sheet (.oeis_style_sheet.txt):

Sequence Warnings Fields warned
A000005 (divisors) 24 %o
A000010 (totient) 12 %o, %H
A000040 (primes) 28 %o, %D, %H, %Y
A000041 (partitions) 50 %o, %H
A000045 (Fibonacci) 49 %o, %H, %Y
A000108 (Catalan) 30 %o, %H, %F
A000203 (sigma) 16 %o, %H, %Y
A000217 (triangular) 16 %o, %Y
A000290 (squares) 4 %o, %Y
A001222 (Omega) 14 %o

Development

git clone https://github.com/daedalus/oeis_validator.git
cd oeis_validator
pip install -e ".[test]"

# run tests (218+ passing)
pytest -v

# format
ruff format src/ tests/

# lint + type check
prospector --with-tool ruff --with-tool mypy src/
semgrep --config=auto --severity=ERROR src/

# find unused code
vulture --min-confidence 90 src/

Threat model (adversarial tests)

The test suite (tests/test_adversarial.py) validates the parser and validator against 52 adversarial scenarios across six categories:

Category Examples
Parser Null bytes, BOM, mixed \r\n/\n, RTL overrides, HTML injection, shell injection, 100-term sequences, negative zero, 50 repeated %S lines
Rules Mixed valid/invalid keywords, contradictory keyword pairs, offset > sequence length, 100 cross-references with duplicates, fake language labels, URL-free references
Style Case-variant pattern matching, false-positive avoidance for except for/its/p(n) in formulas
CLI Binary input, empty stdin, large stdin, directory as file, weird filenames, unknown flags, multiple file args
Multi-entry 50-entry bulk parse, mixed keyword sets per entry
Regression Warning-count snapshots per data file, style-sheet field whitelist

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

oeis_validator-0.1.0.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

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

oeis_validator-0.1.0-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

Details for the file oeis_validator-0.1.0.tar.gz.

File metadata

  • Download URL: oeis_validator-0.1.0.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for oeis_validator-0.1.0.tar.gz
Algorithm Hash digest
SHA256 81eceb1d3db82b2be765f0949e8e85f04f9674ac692473b8cd20423a6a3eb4e4
MD5 8a526c5f554142a28b51baf5db809922
BLAKE2b-256 2c2088b42bb359457da1f0a70cfe772879c25cdcd12b1d1d06b9377ef255537b

See more details on using hashes here.

Provenance

The following attestation bundles were made for oeis_validator-0.1.0.tar.gz:

Publisher: pypi-publish.yml on daedalus/oeis_validator

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

File details

Details for the file oeis_validator-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: oeis_validator-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for oeis_validator-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6a1e8bf8b3a1a423a985a47c97683b7a5dc193596eeb30fae88fce8924fba99f
MD5 a6cba0da3b0f0ceca9d2fe82cd78325e
BLAKE2b-256 0e98f917eeed42419298b39410bb6cb6706508fd70ccf13b428ce4514bcf745b

See more details on using hashes here.

Provenance

The following attestation bundles were made for oeis_validator-0.1.0-py3-none-any.whl:

Publisher: pypi-publish.yml on daedalus/oeis_validator

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