
You can definitely use type variables within a type guard function. The PEP already contains a couple of examples of that. Here's how I'd recommend modifying your sample. Note that there's no need for a union type or an `isinstance` check because of the use of the bound TypeVar. ```python T = TypeVar("T", bound=float) def is_nonzero(x: T) -> TypeGuard[T]: return x != 0 a = 3 if is_nonzero(a): reveal_type(a) # int b = 3.14 if is_nonzero(b): reveal_type(b) # float ``` This example is a bit contrived in that "non-zeroness" isn't captured by the type indicated by the TypeGuard, so there's nothing of value a static type checker can do with the information provided by this type guard function. I don't think we should apply the conditional rule you proposed. The rule would have to be more complex than what you stated to handle unions and constrained TypeVars (which are similar to unions). The rule adds complexity in terms of the implementation but more importantly in the mental model for the user. It would introduce an inconsistency while providing little or no additional value. If you think it's advisable to add a new section to the PEP, I can do so.