Skip to content

Conversation

WillAyd
Copy link
Member

@WillAyd WillAyd commented Jul 15, 2019

xref #27396 @simonjayhawkins some of these were just easy cleanups.

Didn't look through all but some of the others are more complicated and probably require in depth review

@WillAyd WillAyd added Clean Typing type annotations, mypy/pyright type checking labels Jul 15, 2019
lengths = []

meta_vals = defaultdict(list) # type: DefaultDict
if not isinstance(sep, str):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose this would break code if someone tried to provide a non-str sep but that's not documented and unclear why someone would try that anyway

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could it be a remnant of py2 compatibility? for public methods should we allow bytes in all places where a string is expected?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure but on closer inspection doesn't seem to work in general case anyway:

>>> json_normalize({ 'foo' : { 'bar' : 0 } }, sep=b'.')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/williamayd/clones/pandas/pandas/io/json/_normalize.py", line 266, in json_normalize
    data = nested_to_record(data, sep=sep, max_level=max_level)
  File "/Users/williamayd/clones/pandas/pandas/io/json/_normalize.py", line 106, in nested_to_record
    new_d.update(nested_to_record(v, newkey, sep, level + 1, max_level))
  File "/Users/williamayd/clones/pandas/pandas/io/json/_normalize.py", line 91, in nested_to_record
    newkey = prefix + sep + k
TypeError: can only concatenate str (not "bytes") to str

So just seems like a mistake

@simonjayhawkins simonjayhawkins added this to the 0.25.0 milestone Jul 15, 2019
@jreback jreback merged commit 5688096 into pandas-dev:master Jul 15, 2019
@jreback
Copy link
Contributor

jreback commented Jul 15, 2019

thanks!

@WillAyd WillAyd deleted the easy-typing-warnings branch January 16, 2020 00:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean Typing type annotations, mypy/pyright type checking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants