-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: closes #44312: fixes unwanted TypeError with nullable nested metadata in json_normalize #44325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUG: closes #44312: fixes unwanted TypeError with nullable nested metadata in json_normalize #44325
Conversation
d25e6ca
to
ba914c2
Compare
022cbb6
to
5346a3a
Compare
@@ -389,6 +389,8 @@ def _pull_field( | |||
try: | |||
if isinstance(spec, list): | |||
for field in spec: | |||
if result is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this fixes the issue, the typing suggests result
should be dict[str, Any]
from js
. Is the typing incorrect or the issue more upstream?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the Any
value type on the js dict: once we're one level down we're no longer guaranteed that result
is a Dict. It could be (and in this case is) None.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Proper json typing requires recursive types, which seem to be, as of very recently, tentatively supported: python/mypy#731 (comment). This is a whole other kettle of fish, though, that will no doubt reveal a plethora of similar soundness issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. Could you add an informative message in KeyError
and test it if possible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also pls add a whatsnew note in I/O seciton on 1.4 bug fixes
5346a3a
to
04eddf9
Compare
… metadata field is missing
04eddf9
to
1f1917d
Compare
thanks @qdbp |
… metadata field is missing (pandas-dev#44325)
Fixes TypeError crash in json_normalize when using errors="ignore" and extracting nullable nested metadata.