Skip to content

Commit

Permalink
Allow arbitrary keyword args in metaclass constructor.
Browse files Browse the repository at this point in the history
Fixes/replaces #2627
  • Loading branch information
coleifer committed Oct 10, 2022
1 parent 732cda2 commit d43c661
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions peewee.py
Expand Up @@ -6268,9 +6268,10 @@ class ModelBase(type):
'only_save_dirty', 'legacy_table_names',
'table_settings', 'strict_tables'])

def __new__(cls, name, bases, attrs):
def __new__(cls, name, bases, attrs, **kwargs):
if name == MODEL_BASE or bases[0].__name__ == MODEL_BASE:
return super(ModelBase, cls).__new__(cls, name, bases, attrs)
return super(ModelBase, cls).__new__(cls, name, bases, attrs,
**kwargs)

meta_options = {}
meta = attrs.pop('Meta', None)
Expand Down Expand Up @@ -6310,7 +6311,7 @@ def __new__(cls, name, bases, attrs):
Schema = meta_options.get('schema_manager_class', SchemaManager)

# Construct the new class.
cls = super(ModelBase, cls).__new__(cls, name, bases, attrs)
cls = super(ModelBase, cls).__new__(cls, name, bases, attrs, **kwargs)
cls.__data__ = cls.__rel__ = None

cls._meta = Meta(cls, **meta_options)
Expand Down

0 comments on commit d43c661

Please sign in to comment.