Skip to main content
Yanked

This release has been yanked by its maintainers, and will be ignored by installers, except when explicitly specified.
Consider using release 1.2.0.post1 instead.
Reason given by maintainers: Bug

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 @opencaptablecoalition/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

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
File Size Uploaded Provenance Actions
ocf_types-1.2.0.tar.gz 26.0 kB With provenance Details for ocf_types-1.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 53.6 kB

Release files / ocf_types-1.2.0.tar.gz

Download URL ocf_types-1.2.0.tar.gz
Size 26.0 kB
Tags Source
SHA-256 checksum
How to use checksums
29afc315255ca0fd21aadb53d84d9303c1202f399debac0d688d8d6e8a3a66c6
BLAKE2b-256 checksum
How to use checksums
ca85294505df701813612649461ef8bc5e0b2a426a4ce8ddb191325509663029
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-py3-none-any.whl

Download URL ocf_types-1.2.0-py3-none-any.whl
Size 27.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
576a986f7a38e317acaaa160a69fe206984da3f3b9684a8d05dc42b780fbd811
BLAKE2b-256 checksum
How to use checksums
25de89b875bcbc34b70d64d6382c4ec2aa4c55367b1273090b6fe2221026a68e
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

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