Я пытаюсь выполнить абстрактный метод, используя шаблон абстрактной фабрики в python, но я, похоже, получаю и ошибка, так как принимает 1 позиционный аргумент, но 2 были заданы.Любые идеи, что здесь не так, пожалуйста?
ниже мой пример кода
Report.py
from abc import ABCMeta, abstractmethod
class Report(metaclass=ABCMeta):
def __init__(self, name=None):
if name:
self.name = name
@abstractmethod
def execute(self, **arg):
pass
ChildReport.py
import json
from Report import Report
class CReport(Report):
def __init__(self, name=None):
Report.__init__(self, name)
def execute(self, **kwargs):
test = kwargs.get('test')
ReportFactory.py
from ChildReport import CReport
class ReportFactory(object):
@staticmethod
def getInstance(reportType):
if reportType == 'R1':
return CReport()
testReport.py
from ReportFactory import ReportFactory
cRpt = ReportFactory.getInstance('R1')
kwargs = {'test' :'test'}
out = cRpt.execute(kwargs)
Ошибка
out = cRpt.execute(kwargs)
TypeError: execute() takes 1 positional argument but 2 were given