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: get_sort_key() missing 1 required positional argument: 'ctx'

See original GitHub issue

What this might mean? I have no idea how to fix this. Or is it a bug in the peewee code?

  File "/Users/Vic/projects/brain2/brain/utils/reports/bi.py", line 449, in sync_author_tasks
    BIAuthorTask.insert_many(author_tasks).on_conflict_replace().execute()
  File "/Users/Vic/projects/brain2/venv/lib/python3.6/site-packages/peewee.py", line 1560, in inner
    return method(self, database, *args, **kwargs)
  File "/Users/Vic/projects/brain2/venv/lib/python3.6/site-packages/peewee.py", line 1631, in execute
    return self._execute(database)
  File "/Users/Vic/projects/brain2/venv/lib/python3.6/site-packages/peewee.py", line 2274, in _execute
    return super(Insert, self)._execute(database)
  File "/Users/Vic/projects/brain2/venv/lib/python3.6/site-packages/peewee.py", line 2049, in _execute
    cursor = database.execute(self)
  File "/Users/Vic/projects/brain2/venv/lib/python3.6/site-packages/peewee.py", line 2637, in execute
    sql, params = ctx.sql(query).query()
  File "/Users/Vic/projects/brain2/venv/lib/python3.6/site-packages/peewee.py", line 549, in sql
    return obj.__sql__(self)
  File "/Users/Vic/projects/brain2/venv/lib/python3.6/site-packages/peewee.py", line 2258, in __sql__
    self._generate_insert(self._insert, ctx)
  File "/Users/Vic/projects/brain2/venv/lib/python3.6/site-packages/peewee.py", line 2181, in _generate_insert
    columns = sorted(accum, key=lambda obj: obj.get_sort_key(ctx))
  File "/Users/Vic/projects/brain2/venv/lib/python3.6/site-packages/peewee.py", line 2181, in <lambda>
    columns = sorted(accum, key=lambda obj: obj.get_sort_key(ctx))
TypeError: get_sort_key() missing 1 required positional argument: 'ctx'

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
mindojo-victorcommented, Jul 7, 2018

Oh, the model contained a bad attribute:

    assigned_at = peewee.DateTimeField

2.10.2 detected this, while 3.5.2 showed this error. After I added the parens, it worked.

Should I close this issue?

0reactions
Insoodcommented, Oct 20, 2020

Whoo that was a fun 2 hrs trying to figure out what was wrong – I was missing the parens after IntegerField

Is there an easier way to detect this issue in the future?

Read more comments on GitHub >

github_iconTop Results From Across the Web

missing 1 required positional argument: 'ctx' - Stack Overflow
The function on_ready is defined twice and the first one is eliminated when the second one is defined. The error is telling you...
Read more >
I am missing 1 required positional argument: (coro) in discord ...
What and where is the object created in the client class in discord.py? Missing 1 required positional argument pygame 1.9.6 Python 3.8.1.
Read more >
Help pls : r/Discord_Bots - Reddit
I have this code: @bot.event async def on_message(self, ctx, ... it says:TypeError: on_message() missing 1 required positional argument: ...
Read more >
Custom function missing argument - PyTorch Forums
The previous code gives me TypeError: forward() missing 1 required positional argument: 'target' . This seems to happen because it takes ctx ......
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