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 callableQuick 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.
- Note the name being called in the failing line (str, input, format, a method name).
- Search the function, module and class for an assignment to that name, including for loops and imports.
- Rename the variable (str -> text, input -> answer) and run again.
- For obj.name(): check whether name became a property or a plain attribute; drop the parentheses.
- For a literal like "a"("b") or a list of tuples, add the missing comma.
# 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.
Related errors
- TypeError: 'module' object is not callable
- AttributeError: 'NoneType' object has no attribute 'x'
- TypeError: __init__() got an unexpected keyword argument 'proxies'
More in Undefined, None and type errors
- TypeError: Cannot read properties of undefined (reading 'x')Node.js
- TypeError: Cannot destructure property 'id' of 'undefined' as it is undefined.Node.js
- TypeError: items is not iterableNode.js
- TypeError: x is not a functionNode.js
- ReferenceError: x is not definedNode.js
- ERR_INVALID_ARG_TYPE: The "path" argument must be of type string. Received undefinedNode.js
- TypeError: 'NoneType' object is not subscriptablePython
- TypeError: 'NoneType' object is not iterablePython
- KeyError: 'email'Python
- IndexError: list index out of rangePython
- TypeError: unsupported operand type(s) for +: 'int' and 'str'Python
- ValueError: invalid literal for int() with base 10: ''Python
- UnboundLocalError: cannot access local variable 'total' where it is not associated with a...Python
- RuntimeError: dictionary changed size during iterationPython
- ValueError: too many values to unpack (expected 2)Python
References: Python docs: built-in functions, What's new in Python 3.8 (missed-comma SyntaxWarning), Ruff rule A001: builtin-variable-shadowing