TypeError arguments 🐍 Python

TypeError: f() takes 1 positional argument but 2 were given

A function was called with more positional arguments than it accepts — very often a method missing self.

Seen on: Python

Meaning

Calling obj.method(x) passes obj as the first argument automatically. A method defined as def method(x) therefore receives two arguments.

Common causes

  • Instance method missing self
  • Wrong number of arguments after a refactor
  • Callback called with extra arguments by a framework

⚡ Quick fix

  1. Add self as the first parameter of instance methods
  2. Use @staticmethod if it doesn’t need self
  3. Match the call to the signature

Detailed fix by platform

Python

  1. python
    class Api:
        def get(self, path): ...

How to diagnose

  1. Signature — How many parameters are declared?
  2. Call — How many are passed (including self)?

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.