Ben
Ben

Reputation: 21615

Why doesn't PyCharm show me type hint validation errors

I'm using PyCharm 2021.2.2 (Community Edition). I'm learning about Python Type Hints from the FastAPI docs. When I write a function like this

def get_name_with_age(name: str, age: int) -> str:
    name_with_age = name + " is this old: " + age
    return 10

Shouldn't Pycharm warn me that I'm attempting to return an int but the function is supposed to return a string? And / or shouldn't it warn me that I can't concatenate a string with an int? Pycharm doesn't warn me about either of these things..

enter image description here

Upvotes: 1

Views: 329

Answers (1)

Ben
Ben

Reputation: 21615

Apparently I was in "power save" mode. Once disabled this, type hint validation started working.

Upvotes: 1

Related Questions