Stixis
Stixis (stixis) is a CSS serializer and validator for Python 3.14+ with zero runtime dependencies. It generates its grammar tables and TypedDict definitions from W3C @webref/css (ed/css/*.json) and builds its test suite from Web Platform Tests (WPT) and Hypothesis.
What it does
- Compiles W3C Value Definition Syntax.
compile_value_syntaxturns@webref/cssgrammars (|,||,&&, juxtaposition,?,*,+,#,{A,B},[...]!,<type [min,max]>,<'prop'>) into aValueNodetree.serialize_valueformats structured Python values against that tree, andcanonicalizevalidates raw CSS token streams. - Validates AST nodes on construction.
FontFace,StyleRule,AtRule,StyleSheet,CommentNode, andRawDeclarationare frozen dataclasses (dataclass(frozen=True, slots=True)) that check selectors, preludes, descriptors, declarations, and comments in__post_init__. - Escapes PEP 750
Template(t"...") slots by context.render_css_templatechecks the CSS tokens before eachInterpolationslot, escapes comments (/* ... */), strings,url(...), and numbers accordingly, and validates the rendered tokens against the targetValueNodegrammar. - Handles five CSS microsyntaxes.
<urange>:parse_urange,format_urange, andcompact_urangefor cascade-shadowing range compaction.<opentype-tag>:font-feature-settings,font-variation-settings, andfont-language-override.<font-src-list>:FontSrc,Url, andLocalFont, enforcingformat()beforetech().<family-name>and<generic-family>: quotes Pythonstrfamily names by default, requiresgeneric("serif")orKeyword("serif")for generic families, and matches WPTfont-family-serialization-001.html.{1,2}descriptor and property ranges:font-weight,font-widthandfont-stretch,font-style: oblique, and metric overrides.
- Includes a read-only CLI.
stixis inspectandstixis checkexit with0for valid input,1for a validation error,2for a usage error, and4for an unknown target.
Quickstart
from stixis import (
Deg,
FontFace,
FontSrc,
Pct,
Px,
SerializationOptions,
StyleRule,
StyleSheet,
compact_urange,
dumps,
generic,
)
if __name__ == "__main__":
woff2_url = "https://example.com/fonts/noto-sans-jp-slice0.woff2"
slice_id = "kana"
size_kb = 18.4
urange = compact_urange(
sorted_target_cps=[0x3000, 0x3041, 0x3042, 0x3044],
forbidden_sorted=[0x3043],
max_gap=0x80,
)
sheet = StyleSheet(
header_comment="Generated by Stixis",
rules=[
FontFace(
comment=t"Slice [{slice_id}] ({size_kb:.1f} KB)",
font_family="Noto Sans JP",
font_style=("oblique", Deg(-10), Deg(20)),
font_weight=(100, 900),
font_width=(Pct(75), Pct(125)),
font_display="swap",
src=t"url({woff2_url}) format(woff2) tech(variations)",
unicode_range=urange,
),
StyleRule(
"body",
{
"font_family": ["Noto Sans JP", generic("sans-serif")],
"font_feature_settings": {"liga": True, "dlig": False},
"margin": Px(0),
},
),
],
)
print(dumps(sheet))
print(dumps(sheet, options=SerializationOptions.cleome()))
CLI usage
# Inspect an at-rule, property, or <type>
uv run stixis inspect @font-face
uv run stixis inspect font-style --json
uv run stixis inspect "<font-src>"
# Validate and canonicalize CSS values
uv run stixis check font-weight "100 900" --at-rule @font-face
uv run stixis check unicode-range "u+3040-309f" --at-rule @font-face
Development and verification
uv sync
uv run python codegen/gen_specs.py --check
uv run python codegen/gen_wpt_tests.py --check
uv run pytest
uv run ruff check
Metadata
Release files for stixis 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| stixis-0.1.2.tar.gz | 141.0 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| stixis-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 225.5 kB
Release files / stixis-0.1.2.tar.gz
| Download URL | stixis-0.1.2.tar.gz |
|---|---|
| Size | 141.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a1391c898794233a978b182402054e9f78878e4ac313528a2938094452bb2192
|
|
BLAKE2b-256 checksum How to use checksums |
5548dc3c0574d3c9bf28ba48b9982d6a58656f4467ddca3c48d3596bf512e12b
|
| 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 Oct 26, 2026.
Transparency logRelease files / stixis-0.1.2-py3-none-any.whl
| Download URL | stixis-0.1.2-py3-none-any.whl |
|---|---|
| Size | 84.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0e3c7737d7364eda4f327f4fd9d8bdf65d1543032ae9384e42ca4eda04bbb730
|
|
BLAKE2b-256 checksum How to use checksums |
b5f749cdb35a33f6407339c28143523193961f484039867cd8ef9681753b541a
|
| 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 Oct 26, 2026.
Transparency logSecurity for stixis 0.1.2
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
All 2 files in this release have been uploaded with provenance metadata.
Attestation for stixis-0.1.2.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 Oct 26, 2026.
Transparency logA 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.