A lightweight utility package for common API-related tasks in Python, including JSON and Pydantic error translators that provide user-friendly Russian messages.
Project description
various_api_tools
A lightweight utility package for common API-related tasks in Python, including JSON and Pydantic error translators that provide user-friendly Russian messages.
📦 Features
- ✅ JSON Error Translator – Translates
JSONDecodeErrorinto clear Russian messages. - ✅ Pydantic Validation Error Translator – Converts Pydantic validation errors into human-readable Russian strings.
- ✅ Easy to integrate – Designed for use in web APIs and data validation pipelines.
🐍 Installation
Install using pip from source or a private repository:
pip install various_api_tools
🧪 Basic Usage
Translate JSON Decode Errors
import json
from various_api_tools.translators.json import DecodeErrorTranslator
try:
json.loads('{"name": "Alice",}')
except json.JSONDecodeError as e:
print(DecodeErrorTranslator.translate(e))
# Output:
# Ошибка конвертации в формате JSON.
# Позиция: 16.
# Описание: не правильно используются двойные кавычки.
Translate Pydantic Validation Errors
from pydantic import BaseModel, ValidationError
from various_api_tools.translators.pydantic import ValidationErrorTranslator
class User(BaseModel):
email: str
try:
User(email=123)
except ValidationError as e:
print(ValidationErrorTranslator.translate(e.errors()))
# Output:
# Поле: "email". Ошибка: "Невалидное строковое значение(str)";
📄 License
MIT License — feel free to use it in any project! 🎉
🧑💻 Made with ❤️ by @dkurchigin
Have questions? Open an issue or contribute to the repo!
🐙 GITVERSE
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 various_api_tools-0.2.1.tar.gz.
File metadata
- Download URL: various_api_tools-0.2.1.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.25.9 CPython/3.13.5 Linux/6.14.0-29-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
041b7f753dffcbb67db160f92dca085ca6a7e66e67374e90df90dafaa65e5b36
|
|
| MD5 |
d357ee488b408a2430db7c63a4467501
|
|
| BLAKE2b-256 |
cea0b22608a4b72d00b76c8ed67944b71a08fc09084a18bed33069f3b1c10a40
|
File details
Details for the file various_api_tools-0.2.1-py3-none-any.whl.
File metadata
- Download URL: various_api_tools-0.2.1-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.25.9 CPython/3.13.5 Linux/6.14.0-29-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e6c307b70f2fb919fcdcd7966b1a092ad8cb936c22db9f9ade080edabad0960
|
|
| MD5 |
ee31d6507339ce2c7fcc62a328138ed4
|
|
| BLAKE2b-256 |
5b13ca78594c8807d0d7099bf5b1f85955e0ecbc89c967b4c82c15dab5502602
|