I would like to propose a change to type guards, in order to make using them in code more readable. However, I am unsure how achievable this added functionality would be: # Specification I would like to have type guards as readable as human text. Currently we use type guards in the following manner: ``` def is_list_of_str(value: list[object]) -> TypeGuard[list[str]]: return all(isinstance(x, str) for x in value) ``` However, this whole TypeGuard with nested syntax isn't really that readable, is it? In TypeScript, I think this problem was solved in a more beautiful way. I would like to propose to use the same syntax as TypeScript for user defined type guards: ``` def is_list_of_str(value: list[object]) -> value is list[str]: return all(isinstance(x, str) for x in value) ``` Since this might not be achievable, because value is not defined at the moment of statically typing, we might want to do something along the lines of either: ``` def is_list_of_str(value: list[object]) -> "value" is list[str]: return all(isinstance(x, str) for x in value) def is_list_of_str(value: list[object]) -> "value is list[str]": return all(isinstance(x, str) for x in value) ``` My preference would be the first one of the above examples, since this combines the readability with the current way used to type hint variables that may be defined later. Please let me know whether or not you think this is worth pursuing, as well as your general thoughts on the subject. - Job