小编Paw*_*wel的帖子

Python 3.6:{method} 的签名与超类型 {Class} 不兼容

在尝试更新我的代码以符合 PEP-484(我使用的是mypy0.610)时,我遇到了以下报告:

$ mypy mymodule --strict-optional --ignore-missing-imports --disallow-untyped-calls --python-version 3.6

myfile.py:154: error: Signature of "deliver" incompatible with supertype "MyClass"

我的课:

from abc import abstractmethod

from typing import Any


class MyClass(object):

@abstractmethod
def deliver(self, *args: Any, **kwargs: Any) -> bool:
    raise NotImplementedError
Run Code Online (Sandbox Code Playgroud)

我的文件.py:

class MyImplementation(MyClass):

[...]

    def deliver(self, source_path: str,
                dest_branches: list,
                commit_msg: str = None,
                exclude_files: list = None) -> bool:

        [...]

        return True
Run Code Online (Sandbox Code Playgroud)

我肯定在这里做错了什么,但我不太明白是什么:)

任何指针将不胜感激。

python type-hinting python-3.x mypy python-typing

9
推荐指数
1
解决办法
3985
查看次数

标签 统计

mypy ×1

python ×1

python-3.x ×1

python-typing ×1

type-hinting ×1