Skip to content

Commit f87680d

Browse files
authored
BUG: Change the prompt on non list record path errors (PR: #56405) (#56802)
change the prompt on non list record path errors
1 parent 8462515 commit f87680d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

pandas/io/json/_normalize.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,8 @@ def _pull_records(js: dict[str, Any], spec: list | str) -> list:
427427
result = []
428428
else:
429429
raise TypeError(
430-
f"{js} has non list value {result} for path {spec}. "
431-
"Must be list or null."
430+
f"Path must contain list or null, "
431+
f"but got {type(result).__name__} at {repr(spec)}"
432432
)
433433
return result
434434

pandas/tests/io/json/test_normalize.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,8 +526,8 @@ def test_non_list_record_path_errors(self, value):
526526
test_input = {"state": "Texas", "info": parsed_value}
527527
test_path = "info"
528528
msg = (
529-
f"{test_input} has non list value {parsed_value} for path {test_path}. "
530-
"Must be list or null."
529+
f"Path must contain list or null, "
530+
f"but got {type(parsed_value).__name__} at 'info'"
531531
)
532532
with pytest.raises(TypeError, match=msg):
533533
json_normalize([test_input], record_path=[test_path])

0 commit comments

Comments
 (0)