{"version":"1.0","type":"rich","title":"Contracts in Python","description":"This example demonstrates runtime type checking for Python function arguments and return values using function annotations and custom validator classes. The code defines a `Validated` metaclass and validator classes like `TypeChecked`, `Range`, and `Positive`, which are combined through the `checked` decorator to enforce constraints such as type and value ranges on parameters like `x`, `y`, and `z`. It uses the `inspect` module to parse function signatures and annotations, and the `functools` module for wrapping. The sample function `f` shows valid and invalid calls, raising `TypeError` for type mismatches and `ValueError` for out-of-range values.","provider_name":"VizHub AI Studio","provider_url":"https://next.vizhub.com","html":"<iframe src=\"https://next.vizhub.com/viz/gist-b87c8adc95e768ebf6366130ad6d85a7?mode=embed\" width=\"960\" height=\"500\" scrolling=\"no\" frameborder=\"1\"></iframe>","width":960,"height":500,"cache_age":3600}