在以更明确的方式实现abstractmethod
时,我收到一个类型警告,为什么这是错误的
我有以下接口
from typing import Any
from abc import abstractmethod, ABCMeta
class SaveDataInterface(metaclass=ABCMeta):
@abstractmethod
def save_data(self, data: Any, *args, **kwargs):
...
在实现以下FileSaver
类时,mypy抛出一个错误error: Signature of "save_data" incompatible with supertype "SaveDataInterface"
class FileSaver(SaveDataInterface):
def save_data(self, data: str, file_path: str, *args, **kwargs):
with open(file_path, 'w') as file:
file.write(data)
在我看来FileSaver.save_data
并没有以某种方式破坏abstractmethod
{
目前没有回答
相关问题 更多 >
编程相关推荐