Pydantic BaseModel supercharged with helper methods for generic and annotation support
Project description
Super Model for Pydantic
I created this package because I needed a centralized place for a Pydantic BaseModel that can 1) return the generic type of the BaseModel and 2) return which field(s) have a certain Annotation.
Installation
Install with pip
pip install pydantic-super-model
Features
- Generic support
- Able to retrieve field(s) with a specific Annotation
Generic Example
from super_model import SuperModel
class UserWithType[T](SuperModel):
"""User model with a generic type."""
id: T
name: str
user = UserWithType[int](id=1, name="John Doe")
user_type = user.get_type() # int
Annotation Example
from typing import Annotated
from super_model import SuperModel
class _PrimaryKeyAnnotation:
pass
PrimaryKey = Annotated[int, _PrimaryKeyAnnotation]
class UserWithAnnotation(SuperModel):
"""User model with an Annotation for a field."""
id: PrimaryKey
name: str
user = UserWithAnnotation(id=1, name="John Doe")
annotations = user.get_annotated_fields(PrimaryKey)
# {"id": 1}
Run Tests
- Install with the
devextra:pip install pydantic-super-model[dev] - Run tests with
pytest .
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 pydantic_super_model-0.0.2.tar.gz.
File metadata
- Download URL: pydantic_super_model-0.0.2.tar.gz
- Upload date:
- Size: 3.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3c075c9ab3be5282c850fc5e4842292eb6a5f146d1c4863b0bd4987b14cea2d3
|
|
| MD5 |
ac816a95a5e67b97feddcb663a5f9700
|
|
| BLAKE2b-256 |
c3e50165cd4209647feb28043fc50b1e5423b445e006480c5122ca442164839e
|
Provenance
The following attestation bundles were made for pydantic_super_model-0.0.2.tar.gz:
Publisher:
publish-to-pypi.yml on julien777z/pydantic-super-model
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pydantic_super_model-0.0.2.tar.gz -
Subject digest:
3c075c9ab3be5282c850fc5e4842292eb6a5f146d1c4863b0bd4987b14cea2d3 - Sigstore transparency entry: 374605991
- Sigstore integration time:
-
Permalink:
julien777z/pydantic-super-model@049ed02b0bdfa5efffff76164130a051c6df4d09 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/julien777z
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@049ed02b0bdfa5efffff76164130a051c6df4d09 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file pydantic_super_model-0.0.2-py3-none-any.whl.
File metadata
- Download URL: pydantic_super_model-0.0.2-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7ef4c31e0582957646eba6b4291c8626455cb0408755865be17b2412291e91e
|
|
| MD5 |
83d4eef3e60ee902d10f1bccdec100b8
|
|
| BLAKE2b-256 |
f1a94ca51ca6fb77708d82e9ecf94d605892c6e0a9175d6d90a5cd461ef664d0
|
Provenance
The following attestation bundles were made for pydantic_super_model-0.0.2-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on julien777z/pydantic-super-model
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pydantic_super_model-0.0.2-py3-none-any.whl -
Subject digest:
e7ef4c31e0582957646eba6b4291c8626455cb0408755865be17b2412291e91e - Sigstore transparency entry: 374606004
- Sigstore integration time:
-
Permalink:
julien777z/pydantic-super-model@049ed02b0bdfa5efffff76164130a051c6df4d09 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/julien777z
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@049ed02b0bdfa5efffff76164130a051c6df4d09 -
Trigger Event:
workflow_dispatch
-
Statement type: