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.1.tar.gz (3.9 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.1-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for qt_pydantic-0.1.1.tar.gz
Algorithm Hash digest
SHA256 19e72680ed66ebc7cf24d060e8ee6336dccfd51869e79a03954e81c1a121a073
MD5 4831930232e7483e5ab352119247b4d9
BLAKE2b-256 3d976e209e8a38b3f8681928498f7ac8f666366e97d17a7943744c0278c003a3

See more details on using hashes here.

Provenance

The following attestation bundles were made for qt_pydantic-0.1.1.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.1-py3-none-any.whl.

File metadata

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

File hashes

Hashes for qt_pydantic-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5c816cd0c8b80f83a1f0e6d1650abdf3cd6928eb3bbc2b63ea63c4a3777552c7
MD5 47cfc1dffe07634aa974f2277dd481d7
BLAKE2b-256 142bef5af14983f4d1d1ffe553386bec84d4e592458c3fb2594326d0f951fef3

See more details on using hashes here.

Provenance

The following attestation bundles were made for qt_pydantic-0.1.1-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