question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: __init__() got an unexpected keyword argument 'ordered'

See original GitHub issue

So I’m using the following: marshmallow (3.0.0) marshmallow-sqlalchemy (0.17.0) psycopg2 (2.8.3) SQLAlchemy (1.3.7)

I’ve got the following: _Tables.py

person_table = Table(
    'person',
    Base.metadata,
    Column('id', UUID(as_uuid=True), primary_key=True, nullable=False, default=sqlalchemy.text('uuid_generate_v4()'), server_default=sqlalchemy.text('uuid_generate_v4()')),
    Column('display_name', String(length=255), nullable=False),
    Column('email', String(length=255), unique=True, nullable=False),
    Column('first_name', String(length=255), nullable=False),
    Column('image', Text),
    Column('last_name', String(length=255), nullable=False),
    Column('phash', Text))

SAObjects.py

class Person(Base):
    def __repr__(self):
        return (
            "<Person id='" + str(self.id)
            + "' first_name='" + self.first_name
            + "' last_name='" + self.last_name + "'>")
    __table__ = person_table

_Schema.py

class BaseOpts(ModelSchemaOpts):
    def __init__(self, meta):
        if not hasattr(meta, "sqla_session"):
            meta.sqla_session = SqlSessionSingleton.get_instance()
        super(BaseOpts, self).__init__(meta)

class BaseSchema(ModelSchema):
    OPTIONS_CLASS = BaseOpts

class PersonSchema(BaseSchema):
    class Meta:
        model = Person

but I am getting the following:

$ python3 db_tester.py
Traceback (most recent call last):
  File "db_tester.py", line 4, in <module>
    from ._Schema import PersonSchema
  File "#####-venv/myproject/tests/myproject/_Schema.py", line 21, in <module>
    class BaseSchema(ModelSchema):
  File "#####-venv/lib/python3.7/site-packages/marshmallow/schema.py", line 112, in __new__
    klass.opts = klass.OPTIONS_CLASS(meta, ordered=ordered)
TypeError: __init__() got an unexpected keyword argument 'ordered'

Did I screw something up?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
sloriacommented, Aug 19, 2019

Your BaseOpts constructor needs to accept ordered or *args, **kwargs.

class BaseOpts(ModelSchemaOpts):
    def __init__(self, meta, ordered=False):
        if not hasattr(meta, "sqla_session"):
            meta.sqla_session = SqlSessionSingleton.get_instance()
        super(BaseOpts, self).__init__(meta, ordered=ordered)
0reactions
frankcashcommented, Dec 6, 2019

how would one do this without creating a shared base model

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - TypeError: __init__() got an unexpected keyword ...
Based on the comments, you're running Django 4.0 with an old version of AllAuth. So you just need to update AllAuth and should...
Read more >
TypeError - unexpected keyword argument 'ordered' #597
When running our tests with marshmallow-2.13.2 and marshmallow-jsonapi-0.10.2, we encountered this stack trace: tests/fa/test_updater.py:3: ...
Read more >
TypeError: __init__() got an unexpected keyword argument ...
After completing all the procedure, the following error was thrown while running run.py TypeError: init() got an unexpected keyword argument ...
Read more >
Flask got an unexpected keyword argument path
8', TypeError: init() got an unexpected keyword argument 'websocket'` if try to simulate this error, it would not generate, this appear out of...
Read more >
TypeError: Field.__init__() got an unexpected keyword ...
Dijango series part 1 section 3 (building a data model) after adding store & tags apps , if i tried to create a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found