0

I would like to have a custom initializer for my PyMODM class. Doing it the straightforward way

class MyModel(MongoModel):
    fields = ...
    def __init__(self, other_args...):
        super().__init__(other_args)
        do_something_else()

produces first a warning:

DeprecationWarning: __class__ not set defining 'MyModel' as <class '__main__.MyModel'>. Was __classcell__ propagated to type.__new__?

and then an error:

TypeError: __init__() missing required positional arguments

What am I missing?

user2286759
  • 189
  • 13

1 Answers1

0

I did this:

class MyModel(MongoModel):
fields = ...
def __init__(self, other_args...):
    super(MyModel, self).__init__(other_args)
    do_something_else()

Works, but i get DeprecationWarning: __class__ not set defining...

Here Provide __classcell__ example for Python 3.6 metaclass they explain more, but I do not understand it at all

  • It doesn't work when you try to retrieve something from the database. I can't add `__classcell__` directly into the `type.__init__` call in the metaclass because that metaclass is part of the library. – user2286759 May 10 '19 at 10:47