简体   繁体   English

为什么 PyCharm 不显示类型提示验证错误

[英]Why doesn't PyCharm show me type hint validation errors

I'm using PyCharm 2021.2.2 (Community Edition).我使用的是 PyCharm 2021.2.2(社区版)。 I'm learning about Python Type Hints from the FastAPI docs .我正在从 FastAPI 文档了解 Python 类型提示 When I write a function like this当我这样写 function 时

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? Pycharm 不应该警告我我正在尝试返回一个 int 但 function 应该返回一个字符串吗? And / or shouldn't it warn me that I can't concatenate a string with an int?和/或它不应该警告我不能将字符串与 int 连接起来吗? Pycharm doesn't warn me about either of these things.. Pycharm 没有警告我这些事情..

在此处输入图像描述

Apparently I was in "power save" mode.显然我处于“省电”模式。 Once disabled this, type hint validation started working.一旦禁用它,类型提示验证开始工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM