Why I have no warning when not all execution path in a function is returning the type hinted expression?

Viewed 47

I have the following function definition:

def my_func(value: int) -> int:
    if value > 10:
        return value + 1
    # return value (suppose, this is what I forgot here)

Many times I forgot the final return statement (in more complex cases) which causing the function accidentally return with None causing run-time error.

For this function definition PyCharm code inspection (all settings default) does not give any warnings. I would expect the inspection to discover, if there are execution paths which do not return with the type hinted function return type.

What am I missing?

0 Answers
Related