Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/324.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 使用pyqt5的mypy检查项目_Python_Python 3.x_Mypy - Fatal编程技术网

Python 使用pyqt5的mypy检查项目

Python 使用pyqt5的mypy检查项目,python,python-3.x,mypy,Python,Python 3.x,Mypy,我试图用它来检查使用的项目。为了让我的问题更清楚,我创建了合成示例,而不是我的代码: from PyQt5.QtCore import QDateTime def date_to_string(date: QDateTime) -> str: return date.toString("dd.MM.yyyy hh:mm:ss") now = QDateTime.currentDateTime() print(date_to_string(now)) 当我跑步时,我得到: 我发

我试图用它来检查使用的项目。为了让我的问题更清楚,我创建了合成示例,而不是我的代码:

from PyQt5.QtCore import QDateTime

def date_to_string(date: QDateTime) -> str:
    return date.toString("dd.MM.yyyy hh:mm:ss")

now = QDateTime.currentDateTime()
print(date_to_string(now))
当我跑步时,我得到:

我发现
/usr/share/qt/qsci/api/python/PyQt5.api

$ grep QDateTime /usr/share/qt/qsci/api/python/PyQt5.api  | grep toString
PyQt5.QtCore.QDateTime.toString?4(Qt.DateFormat format=Qt.TextDate) -> QString
PyQt5.QtCore.QDateTime.toString?4(QString) -> QString
PyQt5.QtCore.QLocale.toString?4(QDateTime, QString) -> QString
PyQt5.QtCore.QLocale.toString?4(QDateTime, QLocale.FormatType format=QLocale.LongFormat) -> QString
这就是我想要的吗

我如何知道如何使用
/usr/share/qt/qsci/api/python/PyQt5.api


另外,我有
/usr/lib/python3.6/site packages/PyQt5/QtCore.pyi
,这个文件需要吗?

是的,mypy需要.pyi文件。
$ grep QDateTime /usr/share/qt/qsci/api/python/PyQt5.api  | grep toString
PyQt5.QtCore.QDateTime.toString?4(Qt.DateFormat format=Qt.TextDate) -> QString
PyQt5.QtCore.QDateTime.toString?4(QString) -> QString
PyQt5.QtCore.QLocale.toString?4(QDateTime, QString) -> QString
PyQt5.QtCore.QLocale.toString?4(QDateTime, QLocale.FormatType format=QLocale.LongFormat) -> QString