Skip to main content

Data specifications by type hints

Project description

typespecs

Release Python Downloads Tests

Data specifications by type hints

Examples

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


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


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

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-1.0.0rc1.tar.gz (70.3 kB view details)

Uploaded Source

Built Distribution

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

typespecs-1.0.0rc1-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file typespecs-1.0.0rc1.tar.gz.

File metadata

  • Download URL: typespecs-1.0.0rc1.tar.gz
  • Upload date:
  • Size: 70.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.11 {"installer":{"name":"uv","version":"0.9.11"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for typespecs-1.0.0rc1.tar.gz
Algorithm Hash digest
SHA256 e2a8e99305ce8540551118da1d259a1e9d7b806e3aeb214493c372ef7296516f
MD5 3382e76235963311e91d33287600492b
BLAKE2b-256 13febaba494d66187555e40a056d134d9d832688c34af64c4f717e8737641802

See more details on using hashes here.

File details

Details for the file typespecs-1.0.0rc1-py3-none-any.whl.

File metadata

  • Download URL: typespecs-1.0.0rc1-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.11 {"installer":{"name":"uv","version":"0.9.11"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for typespecs-1.0.0rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 bad53a50cbbfc739258af05dc460b42e4fc94ed2dfcf7a8ff6dfb399bef4ddbc
MD5 a2db39d5a9414f70b15bd5cedeb0170f
BLAKE2b-256 af8d636b15f4f16bde1beea132ce2d2455f99ff63e5fed7a63f4e13e9496e720

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