def other_function(x: int) -> None: pass def foo(x: int = None) -> None: # Inconsistent; how to do better ? if x is None: x = 4 other_function(x) When I arrive to the line other_function(x) , I'm sure that x is an int. My issue is that the linter (pyright in neovim) believes that x is something like Union[int, None] , so that it does not accept to pass x to the other_function . Is there a way to say "at this point, I know that x is an int " ?...
Originally asked by Laurent Claessens on Stack Exchange (stackoverflow) (CC BY-SA 4.0).