Skip to main content

Data specifications by type hints

Project description

typespecs

Data specifications by type hints

Examples

from dataclasses import dataclass
from typespecs import Spec, from_dataclass
from typing import Annotated as Ann


@dataclass
class Weather:
    temp: Ann[list[float], Spec(kind="data", name="Temperature", units="K")]
    wind: Ann[list[float], Spec(kind="data", name="Wind speed", units="m/s")]
    loc: Ann[str, Spec(kind="meta", name="Observed location")]


weather = Weather([273.15, 280.15], [5.0, 10.0], "Tokyo")
print(from_dataclass(weather))
       kind               name units              data           type
index
temp   data        Temperature     K  [273.15, 280.15]    list[float]
wind   data         Wind speed   m/s       [5.0, 10.0]    list[float]
loc    meta  Observed location  <NA>             Tokyo  <class 'str'>

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

typespecs-0.3.0.tar.gz (63.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

typespecs-0.3.0-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file typespecs-0.3.0.tar.gz.

File metadata

  • Download URL: typespecs-0.3.0.tar.gz
  • Upload date:
  • Size: 63.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.7

File hashes

Hashes for typespecs-0.3.0.tar.gz
Algorithm Hash digest
SHA256 2594f5cde7944af5408aaa6e4220383caa9a7447d9de7a11473192aac0dfbd29
MD5 965d5fc1a522e0d2cecfa1d7834ee902
BLAKE2b-256 623b430abf0efb9096984c0d15da63dc973348ad1461db9f3df978b37b7dd9a5

See more details on using hashes here.

File details

Details for the file typespecs-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: typespecs-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.7

File hashes

Hashes for typespecs-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 da81e87e69a9e35d0bf1d0ed48219e9a5f75abc1d9b72007e2396fc10833b0bd
MD5 f92d0d9d224c9a1709b5858ce695b705
BLAKE2b-256 5ddfd7390e512ea6c684469079427002abb7a3a75e259b53710d2a6b426daed7

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