Skip to main content

Python Strict Types

A lightweight Python library that provides strict numeric types with explicit value boundaries and runtime validation.

Features

  • Strict integer types with defined minimum and maximum values.
  • Automatic validation when creating instances.
  • Clear exceptions for invalid values.
  • No runtime dependencies.
  • Type annotations and PEP 561 support.
  • Compatible with Python 3.10+.

Clone the repository

git clone git@github.com:mishk22555-ux/Python-Strict-types.git

Installation

pip install strict-types

Available Types

Type Minimum Maximum
ByteType -128 127
ShortType -9,000,000 9,000,000
IntegerType -2,000,000,000 2,000,000,000
PercentageType 0 100

All numeric types currently accept integers only.

Usage

Integer Types

from strict_types import ByteType, ShortType, IntegerType

byte = ByteType(127)
short = ShortType(5_000_000)
integer = IntegerType(1_500_000_000)

print(byte)
print(short)
print(integer)

PercentageType

from strict_types import PercentageType

percentage = PercentageType(75)

print(percentage)        # 75
print(repr(percentage))  # 75%

Runtime Validation

Values outside the supported range raise a ValueError.

from strict_types import ByteType

byte = ByteType(200)  # Raises ValueError

Non-integer values raise a TypeError.

byte = ByteType("100")  # Raises TypeError

Arithmetic Operations

Numeric types inherit from Python's built-in int.

from strict_types import ByteType

a = ByteType(100)
b = ByteType(50)

result = a + b

print(result)        # 150
print(type(result))  # <class 'int'>

Arithmetic operations currently return regular Python integers, so range validation is not automatically applied to arithmetic results.

Development

Install development dependencies:

python -m pip install -e ".[dev]"

Run tests:

python -m pytest

Check code quality:

ruff check .
mypy strict_types

Build the package:

python -m build

Project Structure

Python-Strict-types/
├── strict_types/
│   ├── __init__.py
│   ├── base.py
│   ├── integers.py
│   ├── percentage.py
│   └── py.typed
├── tests/
│   └── test.py
├── .gitignore
├── pyproject.toml
└── README.md

License

This project is licensed under the GNU General Public License v3.0 (GPL-3.0-only).

See the LICENSE file for the full license text.

Copyright (C) 2026 Mikhail.

Author

Mikhail

GitHub: https://github.com/mishk22555-ux/Python-Strict-types

Metadata

Release files for strict-types-python 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 strict-types-python 0.1.0
File Size Uploaded Provenance
strict_types_python-0.1.0.tar.gz 15.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for strict-types-python 0.1.0
File Interpreter ABI Platform
strict_types_python-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 31.9 kB

Release files / strict_types_python-0.1.0.tar.gz

Download URL strict_types_python-0.1.0.tar.gz
Size 15.7 kB
Tags Source
SHA-256 checksum
How to use checksums
33d6d675360c8cf2e22f9c8f2fa8eb499d75fa61a28b7f9526c6aa0cf04e8fdc
BLAKE2b-256 checksum
How to use checksums
76802a577925ccd497d2066600c368d4fa6955a5dc9d35f96467b377e45a5dbe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

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

Download URL strict_types_python-0.1.0-py3-none-any.whl
Size 16.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8f68598010d569336cf47df09653e2067750c8e471006efe6d66e723396e9fc3
BLAKE2b-256 checksum
How to use checksums
7e3fb0e84e8e6f669488720982956a5440b9d86f47fe20a12a236207de57d525
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Security for strict-types-python 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.

Release history Release notifications | RSS feed

This release

0.1.0 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