Skip to main content

py-prim

A robust, validated, and state-aware base class architecture for standard Python primitive data types.

In standard Python, primitives like int and str are loose and allow for silent state changes or type mixing. This package provides wrapper classes (Integer, String, etc.) that enforce strict type validation, provide standardized empty/null checks, and offer a consistent API across all basic data types.

Features

Strict Type Validation: Fails fast if you try to assign a string to an integer, or mix up booleans and ints.

Standardized API: Every type implements .is_empty(), .is_null(), and .reset().

Magic Methods Support: Compares cleanly with standard Python types using == and integrates seamlessly with if statements.

Zero Dependencies: Built entirely on the Python standard library.

Installation

You can install this package directly from GitHub using either pip or uv.

Using pip:

pip install git+https://github.com/saliktariq/Py-Prim.git

Using uv:

uv pip install git+https://github.com/saliktariq/Py-Prim.git

Available Types

All types inherit from the Primitive abstract base class:

  • Integer
  • Float
  • String
  • Boolean
  • Bytes

Usage:

Access and mutate the underlying data using the .value property.

from primitives import Integer, String

Initialize with a value

age = Integer(25) print(age.value) # 25

Change the value

age.value = 26 Strict Type Validation The classes automatically validate types upon initialization and assignment, preventing accidental type mixing.

from primitives import Integer

score = Integer(100)

This will raise a ValueError: "Invalid value for Integer: 100.5"

score.value = 100.5

This library strictly isolates Booleans from Integers.

score.value = True # Raises ValueError State Checks and Resets Every type knows what its "empty" and "default" states are.

from primitives import String, Float

name = String("") print(name.is_empty()) # True

name.value = "Alice" print(name.is_empty()) # False

Reset back to the type's default value

name.reset() print(name.value) # ""

Null checking

balance = Float(None) print(balance.is_null()) # True

License

MIT License

Metadata

Release files for py-prim 0.1.0

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

Source distribution (sdist)

Source distribution for py-prim 0.1.0
File Size Uploaded Provenance Actions
py_prim-0.1.0.tar.gz 4.0 kB Without provenance Details for py_prim-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for py-prim 0.1.0
File Interpreter ABI Platform Actions
py_prim-0.1.0-py3-none-any.whl Python 3 none any Details for py_prim-0.1.0-py3-none-any.whl

Total release size: 8.4 kB

Release files / py_prim-0.1.0.tar.gz

Download URL py_prim-0.1.0.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
073b4ec7a6745ff2cc69a9921fc363a4f6ff8ecfb34f77059902bf3bd6356012
BLAKE2b-256 checksum
How to use checksums
31b9ffc0b7f6523fe7822b47a8daa6a0eeca017f5f388af7823f2b131d482d4e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / py_prim-0.1.0-py3-none-any.whl

Download URL py_prim-0.1.0-py3-none-any.whl
Size 4.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
380b33b9a8d9aeecfb17d9247de241c7f9943676547a9bb9e10da144b38a608d
BLAKE2b-256 checksum
How to use checksums
c7feda09632f8ab213265b1a236994de0c55a1ea59aff51d18e51cf001b74f96
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for py-prim 0.1.0

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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