Pydantic-base-aiogram
This code simplifies the conversion of Pydantic schemas into Aiogram handler groups, making it easy to create form-filling handlers.
Installation
pip install pydantic_base_aiogram
Usage:
>>> from enum import Enum
>>> from typing import Union
>>> from pydantic import BaseModel
>>> from pydantic_base_aiogram import SchemaBaseHandlersGroup
# ----------------------------------------utils-methods--------------------------------------
>>> def check_for_properties_existense(cls, properties: list[str]):
... dirs = dir(cls)
... assert len(tuple(filter(lambda x: not x in dirs, properties))) == 0
... assert cls(finish_call=None)
# ----------------------------------------Simple datatypes schema--------------------------------------
>>> class PersonPydanticFormSchema(BaseModel):
... name: str
... age: int
... height: float
...
>>> class PersonFormHanlders(SchemaBaseHandlersGroup[PersonPydanticFormSchema]):
... pass
...
...
>>> check_for_properties_existense(PersonFormHanlders, ['name_view', 'age_view', 'height_view'])
# ----------------------------------------Enum datatype schema-----------------------------------------
>>> class Mood(Enum):
... HAPPY = "😄 Happy"
... SAD = "😢 Sad"
... EXCITED = "🤩 Excited"
... RELAXED = "😌 Relaxed"
...
>>>
>>>
>>> class PersonMoodPydanticFormSchema(BaseModel):
... name: str
... current_mood: Mood
...
>>> class PersonMoodFormHanlders(SchemaBaseHandlersGroup[PersonMoodPydanticFormSchema]):
... pass
...
...
>>> check_for_properties_existense(PersonMoodFormHanlders, ['name_view', 'current_mood_view'])
# ----------------------------------------Complex schema-----------------------------------------------
>>> class Address(BaseModel):
... street: str
... city: str
... postal_code: str
...
>>> class Person(BaseModel):
... name: str
... age: int
... address: Address
...
...
>>> class PersonFormHanlders(SchemaBaseHandlersGroup[Person]):
... pass
...
...
>>> check_for_properties_existense(
... PersonFormHanlders,
... [
... 'name_view',
... 'address_street_view',
... 'address_city_view',
... 'address_postal_code_view'
... ]
... )
...
# ------------------------------------Combined Enum datatype schema------------------------------------
>>> class HappyMood(Enum):
... HAPPY = "😄 Happy"
...
>>> class SadMood(Enum):
... SAD = "😢 Sad"
...
>>> class ExcitedMood(Enum):
... EXCITED = "🤩 Excited"
...
>>> class RelaxedMood(Enum):
... RELAXED = "😌 Relaxed"
...
>>>
>>> class PersonMoodPydanticFormSchema(BaseModel):
... name: str
... current_mood: Union[HappyMood, SadMood, ExcitedMood, RelaxedMood]
... future_mood: HappyMood | SadMood | ExcitedMood | RelaxedMood
...
...
>>> class PersonMoodFormHanlders(SchemaBaseHandlersGroup[PersonMoodPydanticFormSchema]):
... pass
...
...
>>> check_for_properties_existense(PersonMoodFormHanlders, ['name_view', 'current_mood_view'])
Metadata
Release files for pydantic-base-aiogram 1.0.165
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pydantic_base_aiogram-1.0.165.tar.gz | 25.8 kB | Without provenance | Details for pydantic_base_aiogram-1.0.165.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pydantic_base_aiogram-1.0.165-py3-none-any.whl | Python 3 | none | any | Details for pydantic_base_aiogram-1.0.165-py3-none-any.whl |
Total release size: 74.8 kB
Release files / pydantic_base_aiogram-1.0.165.tar.gz
| Download URL | pydantic_base_aiogram-1.0.165.tar.gz |
|---|---|
| Size | 25.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
83a29bba381b8632cd676b1ec95b8855ec616c88d3e6003cf1b05b81430044a3
|
|
BLAKE2b-256 checksum How to use checksums |
43dfc575b52bd4794050d337ff4c2ed225fb51931e2cb1cc29171900dcf14e98
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.10.6 Linux/5.15.0-1064-azure
|
Release files / pydantic_base_aiogram-1.0.165-py3-none-any.whl
| Download URL | pydantic_base_aiogram-1.0.165-py3-none-any.whl |
|---|---|
| Size | 49.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f290a2d0f50b5b202df391151940a28dc6b5ccfbd9b179aa5f7c6f4384e5b997
|
|
BLAKE2b-256 checksum How to use checksums |
4a6ffb8b83ff4174bec13f8d277a662d023c4046789ff57dedcb06c39f6a4cd9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.10.6 Linux/5.15.0-1064-azure
|
Security for pydantic-base-aiogram 1.0.165
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.