对于已经有pylint ignore的行忽略类型提示

7rtdyuoh  于 2021-08-20  发布在  Java
关注(0)|答案(1)|浏览(491)

我想知道如何忽略以下方面的mypy错误:


# check.py

def add(a, b):  # pylint: disable=invalid-name
    return a + b

跑步 mypy . --strict 将提出以下建议:

check.py:1: error: Function is missing a type annotation

那么,我如何忽略这一行以及pylint的输入呢?

vnjpjtjt

vnjpjtjt1#

根据pep 484,首先禁用mypy,然后禁用pylance,应该可以:

def add(a, b):  # type: ignore # pylint: disable=invalid-name
    return a + b

相关问题