【发布时间】:2017-08-01 06:14:29
【问题描述】:
昨天我从 2.7 升级到 3.6。我也开始使用类型提示。这里 是我的代码片段:
import numpy as np
from typing import Union, Tuple, Sequence, Any
Vector = Union[np.ndarray, Tuple[float, float, float]]
Matrix = np.ndarray
Tetra = Tuple[Vector, Vector, Vector, Vector]
...
def transform_ref2tetra(tetra: Tetra) -> Matrix:
""" Return the matrix M that transforms the points of the reference tetra
R=[[1,0,0],[0,1,0],[0,0,1],[0,0,0]] to tetra, i.e., M.R=tetra.
"""
...
在 PyCharm2016.3.2 中,我要求获得快速文档:
def transform_ref2tetra(tetra: Tetra)
Inferred type: (tetra: Tuple[Any, Any, Any, Any]) -> ndarray
Return the matrix M that transforms the points of the reference tetra
R=[[1,0,0],[0,1,0],[0,0,1],[0,0,0]] to tetra, i.e., M.R=tetra.
这不仅仅是文档问题;如果我打电话:
transform_ref2tetra(tetra=("a","b","c","d"))
我没有收到警告(当然,我在运行时收到错误)。
知道发生了什么吗?这是 PyCharm 问题还是我做错了什么?
【问题讨论】:
标签: python python-3.x types pycharm type-hinting