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

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.6.0.tar.gz (43.8 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.6.0-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for velotype-0.6.0.tar.gz
Algorithm Hash digest
SHA256 995db54656090672b756533b796f020dbfe0c3122f3f333aafd1d686c65c175b
MD5 8f467a7ae9b3e4b72a8faf6841096a2b
BLAKE2b-256 571f44f8f437ae1cfccf7843d63fdef11d7c4e2da937b20732165a48528899f1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: velotype-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 14.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.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1d25ed28c026b00710f651264bdc5f8ee85f6949df5cb13b01c2aa8f4bec959c
MD5 c50afe9869f6d2fdc27bdf0c78d2facd
BLAKE2b-256 31e2e315c402f0a71e4b8c0cf76c547d05b2206d65907551ce10b9f545f802c9

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