30 Dec
2020
30 Dec
'20
3:56 p.m.
The expression passed as the first argument should always take on the type indicated by the TypeGuard within the guarded block. In your example, `x` should take on the type `float` within the `if` statement. The name of the type guard function in your example would more accurately be `is_nonzero_float` because that's what you're testing for. The expression `isinstance(x, float)` will always evaluate to false if you pass it an `int`. Perhaps you intended for the type guard function to test for both `float` and `int`? ```python def is_nonzero(x: object) -> TypeGuard[float]: return isinstance(x, (float, int)) and x != 0 ```