I was thinking that if you had a TypeGuard-returning function invoked inside an assert statement, the type of the first parameter should be narrowed for statements following the assert. For example:
UrlStr = NewType('UrlStr', str)
def is_url_str(s: str) -> TypeGuard[UrlStr]: ...
def process(url: str) -> None: assert is_url_str(str) # (type of `url` should be `UrlStr` here) ...
However it doesn't appear the PEP mentions how TypeGuard interacts with assert statements. It just says:
When a conditional statement includes a call to a user-defined type guard function, the expression passed as the first positional argument to the type guard function should be assumed by a static type checker to take on the type specified in the TypeGuard return type, unless and until it is further narrowed within the conditional code block.
I'm not sure an assert statement is necessarily considered "a conditional statement". Could some clarifying language be introduced?