Skip to main content

ocf-types

Python types for the Open Cap Format (OCF), generated directly from the OCF JSON Schemas.

Generated. Do not edit by hand. ocf_types/__init__.py is produced by npm run build:ocf-types-python from the schemas under /schema. It is built at release time and is not committed to the repository.

This is the Python counterpart of @open-captable/ocf-types, the TypeScript types.

Install

pip install ocf-types

The package version is the OCF schema release it was generated from: ocf-types==1.2.0 has the types for OCF v1.2.0. It needs Python 3.10 or later and depends only on typing_extensions.

Usage

import ocf_types as ocf


def quantity_transferred(transfer: ocf.StockTransfer) -> str:
    return transfer["quantity"]


issuer: ocf.Issuer = {
    "object_type": "ISSUER",
    "id": "issuer",
    "legal_name": "Example Co",
    "formation_date": "2022-01-03",
    "country_of_formation": "US",
}

Every type is a TypedDict, a Literal or a union of those, so an OCF object stays the plain dict that json.load gives you. The package adds no behaviour at run time.

What's included

One named type per OCF schema:

  • Objects, types and file wrappers are TypedDict classes. A field the schema does not require is NotRequired.
  • Enums are Literal types: StockClassType = Literal["COMMON", "PREFERRED"].
  • Scalar types are aliases: Numeric = str, Date = str.
  • Versioned schemas are the union of their versions: EquityCompensationIssuance = EquityCompensationIssuanceV1 | EquityCompensationIssuanceV2.

Objects are built the way OCF builds them

OCF composes each object from primitives with allOf. The Python types keep that, where the TypeScript types flatten it:

class Transfer(TypedDict):
    balance_security_id: NotRequired[str]
    resulting_security_ids: list[str]


class StockTransfer(Object, Transaction, SecurityTransaction, Transfer):
    object_type: Literal["TX_STOCK_TRANSFER"]
    quantity: Numeric

So a function that takes a Transfer accepts a stock, convertible, warrant or equity compensation transfer.

For each primitive there is also a union of everything built from it, named Any plus the primitive: AnyTransfer, AnyIssuance, AnyTransaction, AnyObject, AnyConversionTrigger. Use one when code handles every member and should be checked against the fields they share:

def results(transfer: ocf.AnyTransfer) -> list[str]:
    return transfer["resulting_security_ids"]  # every transfer has this


def quantity(transfer: ocf.AnyTransfer) -> str:
    return transfer["quantity"]  # error: a convertible transfer has an amount, not a quantity

Names

The names are the ones the TypeScript types use, without the OCF prefix: StockIssuance here is OCFStockIssuance there. A Python module is its own namespace, so import ocf_types as ocf gives ocf.StockIssuance. To generate with the prefix, pass --prefix OCF to npm run schema:gen-python-types.

What the types do not check

A type says which fields an object has and what each holds. It cannot say everything a JSON Schema does. These are not represented:

  • patterns and formats (a Numeric or a Date is a str);
  • minimums and other limits on a value;
  • conditional requirements, such as "an option has an exercise_price";
  • that no other field is allowed.

Validate OCF data against the JSON Schemas for full correctness, for example with @open-captable/cli. Treat a value as its OCF type once it has passed.

Type checkers

The types are checked in CI with pyright and mypy in strict mode, as an installed package: correct uses must pass, and a set of deliberate mistakes must each be reported.

A schema often narrows a field of a schema it is built from: every object narrows object_type from the ObjectType enum to its own value. The types allow that by declaring such a field ReadOnly in the base class (PEP 705).

An older mypy does not accept that narrowing when it checks the module's own source: mypy 1.18.2 reports "Overwriting TypedDict field", and mypy 2.4.1 does not. This does not affect an installed package, which mypy does not report on. It matters only if you copy ocf_types into your own source tree. As an installed package the types were tested with mypy 1.18.2 and 2.4.1, and pyright 1.1.414.

License

Generated from the OCF schemas. See LICENSE.md.

Metadata

Release files for ocf-types 1.2.0.post1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ocf-types 1.2.0.post1
File Size Uploaded Provenance Actions
ocf_types-1.2.0.post1.tar.gz 26.4 kB With provenance Details for ocf_types-1.2.0.post1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ocf-types 1.2.0.post1
File Interpreter ABI Platform Actions
ocf_types-1.2.0.post1-py3-none-any.whl Python 3 none any Details for ocf_types-1.2.0.post1-py3-none-any.whl

Total release size: 54.5 kB

Release files / ocf_types-1.2.0.post1.tar.gz

Download URL ocf_types-1.2.0.post1.tar.gz
Size 26.4 kB
Tags Source
SHA-256 checksum
How to use checksums
10cd554bf0acacfb8ef158be0ceef17f69db9667fac3adb8d8d6264dff00a206
BLAKE2b-256 checksum
How to use checksums
892b069af498bc398ad54fc4c79f4066aba45c99674675f999fae1ece4554230
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 Nov 27, 2026.

Transparency log

Release files / ocf_types-1.2.0.post1-py3-none-any.whl

Download URL ocf_types-1.2.0.post1-py3-none-any.whl
Size 28.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4070f3a22daa5c9207a225df3a39d9c31b4a9de262c6255e4001416b25811196
BLAKE2b-256 checksum
How to use checksums
0037d298719248db3b19d3c287a89ad52e13b2b20a20cfb7c85261a6d64c60ef
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 Nov 27, 2026.

Transparency log

Security for ocf-types 1.2.0.post1

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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ocf_types-1.2.0.post1.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 Nov 27, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page