Skip to main content

Pydantic BaseModel Annotations for Qt

Project description

qt-pydantic

The qt-pydantic package adds support for Qt types in Pydantic BaseModels. Using these annotations allows for easy serialization and deserialization of Qt types.

Installation

Install using pip:

pip install qt-pydantic

Usage

from PySide6 import QtCore, QtGui
from pydantic import BaseModel
from qt_pydantic import QSize, QColor, QDate


# Define a model with Qt types
class Settings(BaseModel):
    size: QSize
    date: QDate
    color: QColor


# Parse json string into model
json_data = '{"size": [720, 480], "date": "2021-01-01", "color": [255, 95, 135]}'
settings = Settings.model_validate_json(json_data)

# Model types are actual Qt types
assert isinstance(settings.size, QtCore.QSize)
assert isinstance(settings.date, QtCore.QDate)
assert isinstance(settings.color, QtGui.QColor)

# Turn model into json string
data = settings.model_dump_json(indent=2)

Contributing

To contribute please refer to the Contributing Guide.

License

MIT License. Copyright 2024 - Beat Reichenbach. See the License file for details.

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

qt_pydantic-0.1.0.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qt_pydantic-0.1.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file qt_pydantic-0.1.0.tar.gz.

File metadata

  • Download URL: qt_pydantic-0.1.0.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for qt_pydantic-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5e5f858db4412eae732c408f39f7a2c75f62f6ee178768013ddd6e7936ef5435
MD5 dd5445fea1d10ff033d1098dfc90e23d
BLAKE2b-256 0b5bc25e79b4e7f5398f1dff0567b481b82476c4a834a51fe0152a8f30b45a39

See more details on using hashes here.

Provenance

The following attestation bundles were made for qt_pydantic-0.1.0.tar.gz:

Publisher: publish.yml on beatreichenbach/qt-pydantic

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qt_pydantic-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: qt_pydantic-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for qt_pydantic-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 25436baecfceb77c9a9eb35825c734b86f5b71d836e4e25b6f8e2dd8dbd758fa
MD5 4d39c2b893ca10a58cfa68124bd1389e
BLAKE2b-256 3bc9574956e4113dda7b4f1e0174a3de6954990ca35a80253d1aa1641a647fe3

See more details on using hashes here.

Provenance

The following attestation bundles were made for qt_pydantic-0.1.0-py3-none-any.whl:

Publisher: publish.yml on beatreichenbach/qt-pydantic

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page