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 (--cache-dir, --no-cache), 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
Performance, batch cache docs/performance.md
CLI trust model, JSON limits docs/security.md
Public API, IR format_version docs/api-reference.md, docs/stability.md, docs/migration-ir.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.8.0.tar.gz (50.2 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.8.0-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for velotype-0.8.0.tar.gz
Algorithm Hash digest
SHA256 08fc5780c2ecc7a7df9107dc239956d6bf3282274de0f17c1bcaa7eaad773415
MD5 d4807197694cbcbb3239f9d69ac37834
BLAKE2b-256 0c9a6fffe6e91c4d8ea6d484d2fe70377a22f0643fec50a6ca43071ac86ab346

See more details on using hashes here.

File details

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

File metadata

  • Download URL: velotype-0.8.0-py3-none-any.whl
  • Upload date:
  • Size: 14.9 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.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aaa5a6a24e3b80c34a3a4f4c74f43c2242cf88dc626269eb48754c4832f5b93c
MD5 4fc105feed6e73691e3c71df8dcfa927
BLAKE2b-256 26f752c4958eaf62b9697b9133e018f764c2fa090d89d89b93eb0bf73318d26f

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