Skip to content

Easy warning fixups for mypy #27402

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

Merged
merged 1 commit into from
Jul 15, 2019
Merged

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
@@ -280,8 +280,6 @@ def _pull_field(js, spec):
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