The example below does a type check inside a function in order to keep the foo function cleaner. However,the last return values.a gets a static type check error. Pylint does not understand that values.a was already tested for None and it's actually safe to return values.a as a string. class Values(TypedDict): a: str | None b: str | None def raise_if_null(values: Values): if(values.a is None): raise ValueError("bla") if(values.b is None): raise ValueError("bla") def foo(values: Values) -> str: raise_if_null(values) return values.a How can I make pylint aware of the type check inside the function? (This question must have already been answered somehow, I guess. I just cannot find the right search word for it) Continue reading...