Skip to main content

StronglyTypedProperty

Sometimes we need to enforce that a property meets certain type and/or value restrictions because the consumers of that property have made assumptions regarding the data that is stored.

The permissiveness of Python to allow anything to be assigned to a property gives us tremendous flexibility but it can also complicate debugging when things go wrong, especially when the wrong data is written into a property. When this happens we will either have an application that runs to completion without failing but gives an incorrect result or we may get an exception thrown at a point-of-use. Either one of these cases can be time consuming to debug depending on the complexity of the application as we need to find where, why, and when the bad data was written to the variable.

While it can be costly to do this checking at each assignment, there are times when we really wish to lock down a property and restrict what can be assigned to it so that any errors will manifest at assignment rather than a use point. In applications that we need to identify exactly where things go wrong quickly (i.e., fail-fast systems) the value of this may well outweigh the hit on performance that we take.

StronglyTypedProperty provides a Data Class like interface with an additional ability to perform strong type checking as well as value checking on the property created. Type checking operations are performed when values are assigned to the property. The following capabilities are provided:

  • Restrict assigned data to a list of allowable types.
  • Specify the internal sotrage type of the property.
  • Set default values (for read before write situations).
  • Provide optional value checking on assignment in addition to type checking.

Documentation and User Guide

See the User Guide for detailed documentation on the package. This includes the API docs, user guide, and examples.

History

StronglyTypedProperty is pulled from ConfigParserEnhanced into its own module because it is an interesting and useful class. Splitting these up was the intent from the beginning when it was originally developed.

Updates

See CHANGELOG for information on changes.

Metadata

Release files for stronglytypedproperty 0.1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for stronglytypedproperty 0.1.0.1
File Size Uploaded Provenance
stronglytypedproperty-0.1.0.1.tar.gz 10.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for stronglytypedproperty 0.1.0.1
File Interpreter ABI Platform
stronglytypedproperty-0.1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 26.4 kB

Release files / stronglytypedproperty-0.1.0.1.tar.gz

Download URL stronglytypedproperty-0.1.0.1.tar.gz
Size 10.5 kB
Tags Source
SHA-256 checksum
How to use checksums
5694dcecd9c28e4c07df9b3c355c42babee92fd88357f6dee9265931d9de8732
BLAKE2b-256 checksum
How to use checksums
afa560a7c56f661a3f8e43e0e5a6d1013c103fed59a9390a5dd95f4b15a51f6e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / stronglytypedproperty-0.1.0.1-py3-none-any.whl

Download URL stronglytypedproperty-0.1.0.1-py3-none-any.whl
Size 15.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
629478d3aa2707f854c938d05cfca26860853a98b90e3935c4f8c7e052949334
BLAKE2b-256 checksum
How to use checksums
5d000dd0a62d481aad1e8aa52770b0d905c38cf43140b8c92517875c4e20990d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Security for stronglytypedproperty 0.1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page