I am getting a type warning when implementing an abstractmethod
in a more explicit way, why is that wrong?
I have the following interface
from typing import Any
from abc import abstractmethod, ABCMeta
class SaveDataInterface(metaclass=ABCMeta):
@abstractmethod
def save_data(self, data: Any, *args, **kwargs):
...
When implementing the following FileSaver
class, mypy throws an error
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)
It doesn't seem to me that FileSaver.save_data
somehow breaks the abstractmethod
save_data
functionality, Is there another way to implement a more explicit function signature?