Pydantic models for retail products, category trees, and geolocation entities.
Project description
openinflation-dataclass
Typed pydantic models for:
- product cards (
Card); - category trees (
Category); - geolocation and retail entities (
AdministrativeUnit,RetailUnit,Schedule).
The package also includes network serialization helpers:
to_json(value)to convert model data to transport JSON;from_json(payload, model)to restore typed objects from JSON.
Installation
pip install openinflation-dataclass
Quick Start
from io import BytesIO
from openinflation_dataclass import (
AdministrativeUnit,
Card,
Category,
RetailUnit,
Schedule,
from_json,
to_json,
)
category = Category(uid="milk", alias="milk", title="Milk", adult=False)
card = Card(
sku="SKU-001",
plu="123456",
source_page_url="https://example.com/product/sku-001",
title="Milk 1L",
description="Pasteurized milk",
adult=False,
new=True,
promo=False,
season=False,
hit=True,
data_matrix=True,
brand="Example",
producer_name="Example Foods",
producer_country="RUS",
composition="Milk",
meta_data=[],
expiration_date_in_days=10,
rating=4.8,
reviews_count=124,
price=89.9,
discount_price=79.9,
loyal_price=75.9,
wholesale_price=[],
price_unit="RUB",
unit="PCE",
available_count=15,
package_quantity=1.0,
package_unit="LTR",
categories_uid=[category.uid],
main_image=BytesIO(b"main-image"),
)
admin = AdministrativeUnit(
settlement_type="city",
name="Moscow",
alias="moskva",
country="RUS",
region="Moscow",
longitude=37.6176,
latitude=55.7558,
)
retail = RetailUnit(
retail_type="store",
code="STORE-001",
address="Example st, 1",
schedule_weekdays=Schedule(open_from="09:00", closed_from="22:00"),
schedule_saturday=Schedule(open_from="09:00", closed_from="22:00"),
schedule_sunday=Schedule(open_from="10:00", closed_from="21:00"),
temporarily_closed=False,
longitude=37.6176,
latitude=55.7558,
administrative_unit=admin,
categories=[category],
products=[card],
)
payload = to_json(retail)
restored = from_json(payload, RetailUnit)
BytesIO fields are encoded as base64 strings in JSON and restored back to BytesIO on from_json.
Development
python -m pip install -e ".[dev]"
ruff check .
ruff format --check .
pytest
python -m build
twine check dist/*
Publishing to PyPI via Trusted Publisher
The repository contains .github/workflows/publish.yml that publishes via OIDC (no API token).
Optional dry-run publishing is available in .github/workflows/publish-testpypi.yml.
- Create a
pypienvironment in GitHub repository settings. - On PyPI, add a Trusted Publisher for this repository with:
- Owner:
Open-Inflation - Repository:
dataclass - Workflow:
publish.yml - Environment:
pypi
- Owner:
- Create a GitHub Release (or run
workflow_dispatch) to publish. - (Optional) Configure a second Trusted Publisher in TestPyPI for
publish-testpypi.ymland environmenttestpypi, then run that workflow for pre-release validation.
Project details
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 openinflation_dataclass-0.1.5.tar.gz.
File metadata
- Download URL: openinflation_dataclass-0.1.5.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2da6f0f23e57fd5d956cc17edba15b95e672aabcbcc97e3738b5b461afec73c8
|
|
| MD5 |
bf2d29c41b6ea12df0ee7e651a394230
|
|
| BLAKE2b-256 |
07f8f04e4169199af9c5f7a0fd6fce778ec256147729e9e6212fdce0b8e23b59
|
Provenance
The following attestation bundles were made for openinflation_dataclass-0.1.5.tar.gz:
Publisher:
publish.yml on Open-Inflation/dataclass
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openinflation_dataclass-0.1.5.tar.gz -
Subject digest:
2da6f0f23e57fd5d956cc17edba15b95e672aabcbcc97e3738b5b461afec73c8 - Sigstore transparency entry: 1107830388
- Sigstore integration time:
-
Permalink:
Open-Inflation/dataclass@016a1bd6645a5ccaacc0c33d5297a6be10ae6c63 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Open-Inflation
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@016a1bd6645a5ccaacc0c33d5297a6be10ae6c63 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file openinflation_dataclass-0.1.5-py3-none-any.whl.
File metadata
- Download URL: openinflation_dataclass-0.1.5-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
627f3c1654ec1f791c49e48e8bac2ecacfa7f09777def7d31e0362a175b3ed5c
|
|
| MD5 |
e0421525ec10c81b9d9917d432717b90
|
|
| BLAKE2b-256 |
aa6ecc65a90155b05e9a602f9942aa1ce55265ecbfbdf153aee2959e5dde1aff
|
Provenance
The following attestation bundles were made for openinflation_dataclass-0.1.5-py3-none-any.whl:
Publisher:
publish.yml on Open-Inflation/dataclass
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openinflation_dataclass-0.1.5-py3-none-any.whl -
Subject digest:
627f3c1654ec1f791c49e48e8bac2ecacfa7f09777def7d31e0362a175b3ed5c - Sigstore transparency entry: 1107830389
- Sigstore integration time:
-
Permalink:
Open-Inflation/dataclass@016a1bd6645a5ccaacc0c33d5297a6be10ae6c63 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Open-Inflation
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@016a1bd6645a5ccaacc0c33d5297a6be10ae6c63 -
Trigger Event:
workflow_dispatch
-
Statement type: