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
- ✅ 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)
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 sphinxfrom runtime_check import runtime_check
@runtime_check
def greet(name: str) -> str:
return "Hello " + name
print(greet("Alice")) # OK
# greet(123) -> TypeErrorPYTHONPATH=. pytest -qLocal build:
sphinx-build -b html docs/source docs/build
# open docs/build/index.html- GitHub Actions:
.github/workflows/ci.yml - GitLab CI:
.gitlab-ci.yml
MIT