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, velotype batch stub / batch ir, velotype watch stub (optional extra [watch]); 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
velotype batch stub myapp.models --out-dir stubs/
velotype batch ir myapp.models --out-dir ir-json/ --merge
# pip install 'velotype[watch]'
velotype watch stub myapp.models --out-dir stubs/

Batch walks an importable package for dataclasses and writes one .pyi (or merged.pyi with --merge) or JSON per model. Exit codes and failures: docs/troubleshooting-cli.md. Tutorial: docs/tutorial-stubs.md.

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.5.0.tar.gz (40.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.5.0-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: velotype-0.5.0.tar.gz
  • Upload date:
  • Size: 40.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.5.0.tar.gz
Algorithm Hash digest
SHA256 ae9dbbeb5d70ea9fa0840ce9667f968b0f11752da4014ad8d321909f720d3c85
MD5 5fb34583930187f1ec29bccbe62f2c58
BLAKE2b-256 10deb17a9b37a0359a3e1085aba652dde7e6a324222127cd3a46294d89efa47a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: velotype-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 13.7 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.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bcf8b3cbb460a89bb1995e28589020289d11feac4041e63de376144351e1c58b
MD5 5186db352ee749d56c3de67597ca876c
BLAKE2b-256 ccb16d4c2c7876f053b6c632b1b180e09ef7a8810b72320845f2c75d0bf9536b

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