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 Attr, from_dataclass
from typing import Annotated


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


weather = Weather([273.15, 280.15], [5.0, 10.0], "Tokyo")
print(from_dataclass(weather))
      category               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.2.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.2.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: typespecs-0.2.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.2.0.tar.gz
Algorithm Hash digest
SHA256 44e03c149509b9a31fe43476e996a7bc8f3cdb7365109227343d66524461fb2d
MD5 b8f8c3aa36e4b34fee636d40a998dbec
BLAKE2b-256 8918042e979e518a0528c9d57cd877374c45f79d8c229268634ac6e4f2812e7f

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for typespecs-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 48f69427da0d682dbb28b0af82d1e06cc2d17892127be4bbdef7477749c84c23
MD5 3c7279df884d89b51a5dfd3a5cb0759f
BLAKE2b-256 48b40f51496a0e7768c0a4feab14965804b6b88e852230ae9b0cacbb7dd66c31

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