Skip to content

Cartesian-School/runtime-type-checker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CI Python uv

Runtime Type Checker

Minimal decorator @runtime_check that validates function arguments and return values at runtime using Python annotations. No external dependencies.

runtime-type-checker/
├── src/
│   └── runtime_check.py
├── tests/
│   └── test_runtime_check.py
├── docs/
│   └── source/
│       ├── conf.py
│       └── index.rst
├── .github/
│   └── workflows/
│       └── ci.yml
├── .gitlab-ci.yml
├── pyproject.toml
├── README.md
└── .gitignore

Features

  • ✅ Supports int/str/..., Union/Optional, list[T], set[T], tuple[...], dict[K, V]
  • ✅ Preserves function metadata
  • ✅ Pure stdlib (inspect, typing)
  • ✅ CI for linting, typing, testing, docs (GitHub Actions / GitLab CI)

Install (local dev)

This project uses a plain src/ layout without packaging. Just run:

python -m pip install --upgrade pip
pip install -r <(echo -e "ruff\nmypy\npytest\nsphinx")

Or with uv:

uv pip install ruff mypy pytest sphinx

Usage

from runtime_check import runtime_check

@runtime_check
def greet(name: str) -> str:
    return "Hello " + name

print(greet("Alice"))  # OK
# greet(123) -> TypeError

Tests

PYTHONPATH=. pytest -q

Docs

Local build:

sphinx-build -b html docs/source docs/build
# open docs/build/index.html

CI

  • GitHub Actions: .github/workflows/ci.yml
  • GitLab CI: .gitlab-ci.yml

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages