Python Docstring注释,大于和小于符号不显示



我正在使用docstring注释Python代码。注意,这只是一个例子,

def credit_bonus(self, num_purchases: int, total_spend: float)->int:
'''
Calculates eligible and additional credit bonus for a customer, compared to previous
yearly spends, and number of previous purchases.
Additional credit ranking of 2, if current number of purchases > previous purchaces, 
and current spend >= 95% previous spend.
Return: customer's credit ranking
'''
....
return credit_rank

当显示此函数的注释时,在VSCode中,当将鼠标悬停在调用它的另一个模块中的此函数上时,不显示大于符号。我尝试过各种转义字符>,到目前为止都不起作用。

有没有可能冷静下来,<并且>,在Python文档字符串中?

此外,我知道这不是一个停止,也不是命令,只是一个小方便,最终会键入,大于,相反。

感谢和问候,njc

为函数/方法DocStrings工作,而不是为class工作。发布后,我仍在输入<并且>在DocStrings中,我注意到它(现在?(在哪里工作,在哪里不工作。首先是一些规格;

  • Windows 10 Pro x64 20H2
  • Visual Studio代码x64 1.52.1
  • Visual Studio代码的Microsoft Python扩展2020.12.424452561

我确实为函数或方法工作,

def __new_connection(self)->sqlite3.Connection:
'''
__new_connection(self)`->`sqlite3.Connection:n
create a new connection using a connection string, time out, and isolation level settings.n
return:
sqlite3.Connection.
'''
return sqlite3.connect(database=self.__con_str, timeout=self.__timeout, isolation_level=None, uri=True)

>周围键入锐引号或后引号,或者在这种情况下键入->,将显示<并且>符号,当为方法的描述显示DocString时。

但是

对于类文档字符串,它不起作用。

class Broker:
'''
class wrapper for sqlite3 database objects and operations.n
transaction type: auto-commit.n
database type: file system database. not in-memory (:memory:)
isolation level is set to None, i.e. auto-commit, cache is private.
methods:n
__new_connection(self)->sqlite3.Connection
creates a new sqlite3 connection object
__cursor_execute(self, conn: sqlite3.Connection, sqlCmd: str, params: tuple=())->sqlite3.Cursor
creates a cursor object, execute a parameterised sql statement
'''

无论在<或者>。

如果我找到了类DocStrings的变通方法,我会再次发帖,假设它不起作用(仍然(,如果我起作用的话。

谢谢和问候,njc

最新更新