python - 打开 Path 对象时 Pycharm 类型提示警告
问题描述
使用以下代码:
from pathlib import Path
file = Path("test.txt")
with open(file) as fl:
pass
Pycharm 给出以下警告file
Unexpected type(s): (Path)
Possible types:
(Union[str, bytes, int])
(Union[str, bytes, int, PathLike]) less... (Ctrl+F1)
Inspection info: This inspection detects type errors in function call expressions. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Types of function parameters can be specified in docstrings or in Python 3 function annotations.
难道我做错了什么 ?
解决方案
推荐阅读
- asp.net - 错误:asp.net 中位置 0 处没有行
- javascript - Shopify 博客页面中的动态数据
- python - Python 3 中的 re.sub
- airflow - 无法让 ECSOperator (Fargate) 与 Airflow 一起工作
- ios - 使用 UITable 显示数据但显示错误
- reactjs - onChange 在哪里将参数传递给它的处理程序
- php - 从该包中确定 Composer 包的当前安装版本
- c# - 通过 CreateFileA OPEN_EXISTING 参数更改属性后的 MS Access 安全警告
- python-3.x - 用漂亮的汤从 div 标签中刮取 href
- swift - Codable 和 CodingKeys