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

Built distribution (wheel)

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

Total release size: 31.9 kB

Release files / strict_types_python-0.1.1.tar.gz

Download URL strict_types_python-0.1.1.tar.gz
Size 15.7 kB
Tags Source
SHA-256 checksum
How to use checksums
7d774439df56978a0fcd6f1f91c65869c269cbf20c82d9f105aa296f60e86aaf
BLAKE2b-256 checksum
How to use checksums
7028037b9331962959cd707f73732140b0e167e81ed5d995151934a8a1a0b538
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.1-py3-none-any.whl

Download URL strict_types_python-0.1.1-py3-none-any.whl
Size 16.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8c9f9673a245562baad99d670add17f2757b10f5a5f637d648ac62f4cdfc7cf2
BLAKE2b-256 checksum
How to use checksums
8df5282f47b9ca3cae795c99d8ee8d0d3cfc7b90790e32e28d6c26a0e9014385
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.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.

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

Release history Release notifications | RSS feed

This release

0.1.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