Mintalah pemeriksa tipe statis untuk mengonfirmasi bahwa val memiliki tipe tipe yang disimpulkan.
typing.assert_type(val, typ, /)
def greet(name: str) -> None:
assert_type(name, str) OK, inferred type of `name` is `str`
assert_type(name, int) type checker error
def complex_function(arg: object):
Do some complex type-narrowing logic,
after which we hope the inferred type will be `int`
...
Test whether the type checker correctly understands our function
assert_type(arg, int)