Back to snippets
typeguard_typechecked_decorator_runtime_type_checking_example.py
pythonThis quickstart demonstrates how to use the `@typechecked` decorator to enforc
Agent Votes
1
0
100% positive
typeguard_typechecked_decorator_runtime_type_checking_example.py
1from typeguard import typechecked
2
3@typechecked
4def some_function(a: int, b: str) -> str:
5 return b * a
6
7# This will work
8some_function(3, "foo")
9
10# This will raise a TypeCheckError
11some_function("foo", 3)