Skip to main content

Velarium IR to .pyi stub generation (velotype backend)

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

velotype

PyPI version Python versions License: MIT

Role in Velarium: IR → .pyi — render Velarium (ModelSpec) IR as minimal stub text, and expose the velotype CLI for quick IR export and stub generation from live classes.

PyPI pypi.org/project/velotype
Repository github.com/eddiethedean/velarium
Python 3.10+ (follows velarium)
Depends on velarium on PyPI (required)
CLI velotype ir, velotype stub (also python -m velotype)

The IR types and builders live in velarium. velotype re-exports the same public IR symbols and builder entry points as velarium (including modelspec_from_pydantic_model and modelspec_from_attrs_class when extras are installed); prefer from velarium import … in new code when you only need IR. See docs/model-sources.md for optional dependencies.

Stub output: generate_pyi / render_typespec aim for valid, checker-friendly .pyi text. Optional generate_pyi arguments include module_docstring, header / footer, include_all (emits __all__), and style ("default" banner vs "minimal"). Optional format_stub_text(..., backend="ruff") runs ruff format - when available. Advanced TypeKind values (protocol, nominal, paramspec, typevartuple, and bare typevar in fields) are rendered as typing.Any in stubs so generated files do not invent TypeVar/ParamSpec declarations; the JSON IR still carries name / qualname / module for tooling.

Topic Doc
Stub fallbacks docs/supported-annotations.md
Guarantees, imports, CI mypy / Pyright docs/stub-compatibility.md

Install

pip install velotype

From the monorepo root:

uv sync --group dev
# or
pip install -e packages/velarium -e "packages/velotype[dev]"

CLI

velotype ir myapp.models:User
velotype ir myapp.models:User -o user.ir.json
velotype stub myapp.models:User -o user.pyi

Exit codes: 2 for bad target syntax, missing module, unresolvable import path, or target not a class; 1 when the class is not a dataclass (or other modelspec_from_dataclass failure).

Library

from velarium import modelspec_from_dataclass, dumps_model_spec
from velotype import format_stub_text, generate_pyi

spec = modelspec_from_dataclass(MyModel)
print(generate_pyi(spec))
# Optional: print(format_stub_text(generate_pyi(spec), backend="ruff"))

Version

__version__ is in velotype/__init__.py (Hatch dynamic metadata in this package’s pyproject.toml).

See also

License

MIT — see LICENSE.

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

velotype-0.4.0.tar.gz (32.4 kB view details)

Uploaded Source

Built Distribution

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

velotype-0.4.0-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file velotype-0.4.0.tar.gz.

File metadata

  • Download URL: velotype-0.4.0.tar.gz
  • Upload date:
  • Size: 32.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for velotype-0.4.0.tar.gz
Algorithm Hash digest
SHA256 e49fd21828398ab36962df2ec20941cc8265656e6a6096afaf698ebae86e1653
MD5 bb1bbee33b719735112be84d2c473f7c
BLAKE2b-256 7578999b111a0c56712e88d2c45bfd5626229e87cddfdbf624596836eb70fb31

See more details on using hashes here.

File details

Details for the file velotype-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: velotype-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for velotype-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3df44488b930f77927490109b9d2e47cd5817c5fd9de2bdaac5cc7b1b647e1fa
MD5 11e06cb1bc25359babaeaac9d9546190
BLAKE2b-256 9fc0c697d0474858de0e0641555291fe14bccef891a6976965ae4578e6236aa2

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