Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/363.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在函数docstring中记录“tuple”返回类型以提示PyCharm类型_Python_Pycharm_Docstring - Fatal编程技术网

Python 在函数docstring中记录“tuple”返回类型以提示PyCharm类型

Python 在函数docstring中记录“tuple”返回类型以提示PyCharm类型,python,pycharm,docstring,Python,Pycharm,Docstring,我如何记录一个函数返回一个元组,这样PyCharm就可以使用它来提示类型了 人为的例子: def fetch_abbrev_customer_info(customer_id): """Pulls abbreviated customer data from the database for the Customer with the specified PK value. :type customer_id:int The ID of the Customer

我如何记录一个函数返回一个
元组
,这样PyCharm就可以使用它来提示类型了

人为的例子:

def fetch_abbrev_customer_info(customer_id):
  """Pulls abbreviated customer data from the database for the Customer
       with the specified PK value.

       :type customer_id:int The ID of the Customer record to fetch.

       :rtype:???
  """
  ... magic happens here ...

  return customer_obj.fullname, customer_obj.status #, etc.

我联系了PyCharm支持部门,他们是这么说的:

对于元组,请使用
(,,e t.c.)
语法

例如:

这在以下方面得到证实:

类型语法 Python DocString中的类型语法没有任何标准定义。因此,PyCharm建议使用以下符号:

  • (Foo,Bar)#Foo和Bar的元组

:returns:customer name:his name,customer status:his status,customer's dog's name:通常为Fido。整个字符串不能是
“Return(name,status等)”
?其他一切似乎都有点多余。除非PK值与函数期望的客户id类型有关。更新了问题文本,使其不那么主观。我认为从PyCharm 2017.1.5开始,这一点已经被打破
"""
:rtype: (string, int, int)
"""