Pycharm类型提示警告打开路径对象

时间:2019-03-11 14:11:36

标签: python pycharm typehints

使用以下代码:

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.

我做错什么了吗?

0 个答案:

没有答案