Skip to main content

pydantic-tools

pdm-managed codecov

GitHub Actions Python

A set of tools for pydantic(i18n, alias(comming soon), etc.)

Installation

pip install pydantic-tools

i18n

A simple example

from pydantic_tools import i18n
class TestModel(i18n.BaseModel_i18n):
    name: str
    age: int

    class Config:
        locale = "zh_cn"

test = TestModel()
pydantic.error_wrappers.ValidationError: 2 validation errors for TestModel
name
  确保该值不缺失 (type=value_error.missing)
age
  确保该值不缺失 (type=value_error.missing)

Config available

  • locale: The locale of the model, default is None, which means no translation enabled, and the default error message will be used. Use python -m pydantic_tools.i18n -l to show all available locales.

  • locale_strict: Whether to raise an error when the locale is not found, default is False.

  • translations: If specified, the error messages will be translated according to the given dict instead of the locale config. The dict should be like {"value_error.missing": "Missing"}. One of locale and translations should be specified, do not set both of them.

  • extra_translations: If specified, an extra dict will be merged into the default translations. The dict should be like {"value_error.missing": "some msg"}.

Show all available locales

python -m pydantic_tools.i18n -l

Show all available translations

python -m pydantic_tools.i18n -t

alias

Comming soon

Release files for pydantic-tools 0.3.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pydantic-tools 0.3.3
File Size Uploaded
pydantic_tools-0.3.3.tar.gz 6.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pydantic-tools 0.3.3
File Interpreter ABI Platform
pydantic_tools-0.3.3-py3-none-any.whl Python 3 none any Details

Total release size: 13.6 kB

Release files / pydantic_tools-0.3.3.tar.gz

Download URL pydantic_tools-0.3.3.tar.gz
Size 6.5 kB
Tags Source
SHA-256 checksum
How to use checksums
707358b1c73887df95efe622b23279f3053a66254b2d17251b1262934edffecf
BLAKE2b-256 checksum
How to use checksums
77866532e72c8e3e891e6b3e578768fa473f664a51319111f1486041a0c235a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.3

Release files / pydantic_tools-0.3.3-py3-none-any.whl

Download URL pydantic_tools-0.3.3-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
27275f4f0aeb670870d5d16fe13fae537b1d4506565ecf5e7260a002e01453d6
BLAKE2b-256 checksum
How to use checksums
587794f8c0301fe06ea521b138fe580658cfcca451f4b07751fe5e2bb3456e15
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.3

Release history Release notifications | RSS feed

This release

0.3.3 This release

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page