{"id":22505,"library":"typing-validation","title":"Typing Validation","description":"A lightweight, dependency-free runtime type-checking library for Python that validates values against arbitrary type annotations, including generics, TypeVars, and nested types. Current version is 1.2.12, released irregularly with incremental features and bug fixes.","status":"active","version":"1.2.12","language":"python","source_language":"en","source_url":"https://github.com/hashberg-io/typing-validation","tags":["type-checking","runtime validation","typing","validation"],"install":[{"cmd":"pip install typing-validation","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Required for backward compatibility with Python < 3.11 (e.g., Self, TypeVarTuple)","package":"typing_extensions","optional":true},{"reason":"Optional: required for validation against NDArray[dtype] annotations","package":"numpy","optional":true}],"imports":[{"note":"","wrong":"","symbol":"validate","correct":"from typing_validation import validate"},{"note":"","wrong":"","symbol":"is_valid","correct":"from typing_validation import is_valid"},{"note":"","wrong":"","symbol":"InvalidTypeException","correct":"from typing_validation import InvalidTypeException"}],"quickstart":{"code":"from typing_validation import validate\n\n# Validate a simple type\nx: int = 10\ntry:\n    validate(x, int)\n    print(\"Valid\")\nexcept InvalidTypeException as e:\n    print(f\"Invalid: {e}\")\n\n# Use with assertions (compiled away with -O)\nfrom typing_validation import is_valid\nif is_valid(x, int):\n    print(\"x is int\")","lang":"python","description":"Basic usage: validate() raises on mismatch, is_valid() returns bool, assertion trick for performance."},"warnings":[{"fix":"Use is_valid() for boolean checks, or use assert validate(...) to suppress return value.","message":"In v1.2.6, validate() return type changed from None to Literal[True]. Code relying on return value (e.g., if validate(...)) may break.","severity":"breaking","affected_versions":">=1.2.6"},{"fix":"Import validate or is_valid instead.","message":"Do not use from typing_validation import valid; that import does not exist.","severity":"deprecated","affected_versions":"all"},{"fix":"Cast or convert values explicitly before or after validation if needed.","message":"Validate does not perform coercion; it only checks types. If validation passes, the value is unchanged.","severity":"gotcha","affected_versions":"all"},{"fix":"Test thoroughly with complex generics, or use alternatives like pydantic for strict runtime checks.","message":"Support for Type[T] is partial (see issue #18). Some edge cases with generic type variables may not raise.","severity":"gotcha","affected_versions":">=1.2.10"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Change to 'from typing_validation import validate'","cause":"Typo: 'valid' is not exported; correct function is 'validate'.","error":"AttributeError: module 'typing_validation' has no attribute 'valid'"},{"fix":"Run 'pip install typing-validation' and ensure the virtual environment is activated.","cause":"Package not installed or installed incorrectly.","error":"ImportError: cannot import name 'validate' from 'typing_validation'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}