Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion astroid/brain/brain_builtin_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ def _infer_str_format_call(

try:
formatted_string = format_template.format(*pos_values, **keyword_values)
except IndexError:
except (IndexError, KeyError):
# If there is an IndexError there are too few arguments to interpolate
return iter([util.Uninferable])

Expand Down
3 changes: 3 additions & 0 deletions tests/unittest_brain_builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ def test_string_format(self, format_string: str) -> None:
"My name is {}, I'm {}".format(Unknown, 12)
""",
""""I am {}".format()""",
"""
"My name is {fname}, I'm {age}".format(fsname = "Daniel", age = 12)
""",
],
)
def test_string_format_uninferable(self, format_string: str) -> None:
Expand Down