A Python library for extracting field metadata from dataclasses and Pydantic models
Project description
fields-metadata
A Python library for extracting comprehensive field metadata from dataclasses and Pydantic models, with support for derived fields, custom annotations, filtering/sorting/grouping via therismos, and recursive traversal of nested structures.
Installation
pip install fields-metadata
pip install "fields-metadata[pydantic]" # with Pydantic support
Quick Start
from dataclasses import dataclass
from typing import Annotated
from annotated_types import DocInfo, Ge
from fields_metadata import MetadataExtractor, HumanReadableId
@dataclass
class Person:
name: Annotated[str, HumanReadableId(), DocInfo("Full name")]
age: Annotated[int, Ge(0)]
email: str | None = None
extractor = MetadataExtractor()
metadata = extractor.extract(Person)
print(metadata["name"].doc) # "Full name"
print(metadata["age"].numeric) # True
print(metadata["email"].optional) # True
Full documentation: fields-metadata.readthedocs.io
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fields_metadata-1.8.0.tar.gz.
File metadata
- Download URL: fields_metadata-1.8.0.tar.gz
- Upload date:
- Size: 43.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b6120d66f37f8a4bfb0f77f2bbe70c4304e467a07b45b541ff7b368f8e7ce0d
|
|
| MD5 |
78b51d72c61047049f919f3cac2d8297
|
|
| BLAKE2b-256 |
97a35d8391c162a15448f06a91ecbab2ee8f93fe9d944d9342b80acbad143039
|
File details
Details for the file fields_metadata-1.8.0-py3-none-any.whl.
File metadata
- Download URL: fields_metadata-1.8.0-py3-none-any.whl
- Upload date:
- Size: 19.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad48e2ba739566cf47c7a90990077f7ac2bb73bbe4109bceebca2862419758f9
|
|
| MD5 |
7c0a6e3cfd192d847db47b809db7b860
|
|
| BLAKE2b-256 |
fb501162946676e6ad7dc4d0defe6d4050ab2b0bd023ec9d7550c2250997b3e4
|