Skip to main content

Auto type cast dataclasses to suggested types.

Project description

strictdataclass

Sections:

Purpose

This package contains the necessary base class structure for strict, auto-casting dataclasses for use in an inheritence architecture. The inheritable base class has custom double-underscore (dunder), convenience, and property methods.

Contents

This package contains two modules written in pure Python (3.7 or newer) with the following code blocks accessible from the root module:

  • StrictDataclass: Inheritable base class for automatic type casting on instantiation
  • ObjectTypeNotCastableError: Error raised when type casting fails

Installation

This package is distributed to PyPi, and can be installed with either of the following commands:

  • pip install strictdataclass
  • pip3 install strictdataclass

Usage

Inherit the base class StrictDataclass in a dataclass-decorated class definition to inherit the type casting properties.

Declaration

@dataclass
class Foo(StrictDataclass):
    bar: bool
    foo: int = 5

Issues/Limitations

Although there are currently no known cast failing cases or performance issues, this package is in its infancy and has been marked as:

Beta

Author

Braden Toone is the sole author and maintainer of this code, and can be contacted via email at braden@toonetown.com

License

This package is licensed under the OSI Approved MIT License for free commercial and personal use as stated in the LICENSE file.

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

strictdataclass-0.1.0.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

strictdataclass-0.1.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: strictdataclass-0.1.0.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.1

File hashes

Hashes for strictdataclass-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1e7c7047e80310ec33c52c4449103bb0ab242afcb682022959fcf2f66f2f263e
MD5 c173510f7af31bb13632c979a85e0f44
BLAKE2b-256 9fcb2d2188b05a7813518280cc1b9a80e8fc10dfbe1a123892a6f4e9d7f86e59

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for strictdataclass-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 732e3fa006e084cc70783b5a45ae676014d89088558d05782dab5d54ea4ba5c1
MD5 f83762bf59dedf62dac01cb3c02fe6e8
BLAKE2b-256 dac26801c054ee86ff7835f414d2e11fb55c4f907283edd116050f955f0b913b

See more details on using hashes here.

Supported by

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