TypeError: 'str' object is not callable

Python · updated 2026-11-04

Raised when code puts parentheses after a value that is a string. The name in the failing line refers to a string at that moment, even if it looks like a function, usually because something earlier assigned a string to that name.

Traceback (most recent call last):
  File "/app/billing/invoice.py", line 41, in render
    label = str(invoice.number)
            ^^^^^^^^^^^^^^^^^^^
TypeError: 'str' object is not callable

Quick fix

Look for an assignment to the name you are calling, in the same function, module or class: str = ..., input = input(), format = ..., or a property that replaced a method. Rename the variable so it no longer shadows the built-in or method. If the call is on a string literal, a comma is missing between two items.

  1. Note the name being called in the failing line (str, input, format, a method name).
  2. Search the function, module and class for an assignment to that name, including for loops and imports.
  3. Rename the variable (str -> text, input -> answer) and run again.
  4. For obj.name(): check whether name became a property or a plain attribute; drop the parentheses.
  5. For a literal like "a"("b") or a list of tuples, add the missing comma.
python
# Before: the loop variable shadows the built-in str
for str in invoice.lines:
    ...
label = str(invoice.number)   # TypeError: 'str' object is not callable

# After
for line in invoice.lines:
    ...
label = str(invoice.number)

# Missing comma between strings in a call or list
names = ["alice" "bob"]        # joined into "alicebob"
greeting = "hi"("there")       # SyntaxWarning: perhaps you missed a comma?

Why it happens

A variable shadows a built-in

str = ..., input = input(), format = ..., type = ... or a loop variable with one of those names. Every later call to the built-in in that scope calls the string instead. A module-level assignment breaks the whole module.

A method became a string attribute

self.name = "x" in __init__ replaces a method called name, or a @property returns a string and the caller still adds ().

Missing comma or operator

Two literals next to each other, such as "%s" (value) instead of "%s" % (value), or a list of strings where one comma is missing. Python 3.8+ warns at compile time when it sees a call on a literal: "perhaps you missed a comma?"

Shadowed in a notebook or REPL

An earlier cell assigned str or another built-in. The error stays until the kernel restarts or the name is deleted with del.

Other fixes

  • Linters catch this: Ruff and Pylint flag names that shadow built-ins (Ruff rules A001-A003, Pylint redefined-builtin).
  • In a REPL or notebook, del str restores the built-in.

Same error, other wording

  • TypeError: 'int' object is not callable
  • TypeError: 'list' object is not callable
  • SyntaxWarning: 'str' object is not callable; perhaps you missed a comma?

Let your coding agent catch the next one

Runheed records this error in production with the stack trace, the breadcrumbs before it and the agent session that shipped the code, and serves it to Claude Code, Cursor or any MCP client. With it connected, you can ask:

> Find the "'str' object is not callable" errors in production, find where that name was assigned a string earlier in the scope, and rename it so the built-in or method is called again.

Plans from $29/moSee what your agent readsSee the setupCancel any time from the billing portal

Related errors

More in Undefined, None and type errors

References: Python docs: built-in functions, What's new in Python 3.8 (missed-comma SyntaxWarning), Ruff rule A001: builtin-variable-shadowing