Я определил в каком-то классе Класс1 следующий список:
class Class1(BaseModel): # BaseModel is the ORM's base model
_name = ""
_year = 0
.....
VALUE_LIST = ['a', 'b', 'c]
def __init__(self, name, year, ........):
self._name = name
self._year = year
......
и в другом файле file_x.py , я импортировал класс и использовал список как это:
from myproj.models.class1 import Class1
_value = fields.List(
attribute='value', data_key='value',
required=False, allow_none=True, validate=validate.OneOf(Class1.VALUE_LIST,
error='value is not allowed'))
Затем, когда я запускаю тесты, я получаю:
ImportError while loading conftest '/home/ubuntu/PycharmProjects/xmaker_application_manager/xmaker_mgr_app/test/conftest.py'.
__init__.py:5: in <module>
from xmaker_mgr_app.controllers.user_controller import UserOperator
../controllers/user_controller.py:5:
in <module>
from xmaker_mgr_app.bl.user_operator import UserOperator
../bl/user_operator.py:8:
in <module>
from xmaker_mgr_app.bl.file_x import UserSchema
../bl/file_x.py:177:
in <module>
class Class1Schema(ma.ModelSchema):
../bl/file_x.py:211:
in Class1Schema
required=False, allow_none=True, validate=validate.OneOf(Class1.VALUE_LIST, error='value is not allowed'))
E TypeError: __init__() missing 1 required positional argument: 'cls_or_instance'
Как мне это исправить?
Спасибо