Skip to content

#29886 - Replace !r for repr() on pandas/io/parses.py #30073

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 16 commits into from
Dec 10, 2019
Merged
Show file tree
Hide file tree
Changes from 7 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
4 changes: 2 additions & 2 deletions pandas/io/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def _get_skiprows(skiprows):
elif skiprows is None:
return 0
raise TypeError(
"%r is not a valid type for skipping rows" % type(skiprows).__name__
f"{repr(type(skiprows).__name__)} is not a valid type for skipping rows"
)


Expand Down Expand Up @@ -133,7 +133,7 @@ def _read(obj):
except (TypeError, ValueError):
pass
else:
raise TypeError("Cannot read object of type %r" % type(obj).__name__)
raise TypeError(f"Cannot read object of type {repr(type(obj).__name__)}")
return text


Expand Down
10 changes: 5 additions & 5 deletions pandas/io/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -913,8 +913,8 @@ def _get_options_with_defaults(self, engine):
pass
else:
raise ValueError(
"The %r option is not supported with the"
" %r engine" % (argname, engine)
f"The {repr(argname)} option is not supported with the"
f" {repr(engine)} engine"
)
else:
value = _deprecated_defaults.get(argname, default)
Expand Down Expand Up @@ -3600,15 +3600,15 @@ def __init__(self, f, colspecs, delimiter, comment, skiprows=None, infer_nrows=1
self.comment = comment
if colspecs == "infer":
self.colspecs = self.detect_colspecs(
infer_nrows=infer_nrows, skiprows=skiprows
infer_nrows=infer_nrows, skiprows=skiprow
Copy link
Member

@ShaharNaveh ShaharNaveh Dec 5, 2019

Choose a reason for hiding this comment

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

You accidentally deleted the 's' here:)

Suggested change
infer_nrows=infer_nrows, skiprows=skiprow
infer_nrows=infer_nrows, skiprows=skiprows

Copy link
Contributor Author

@JvPy JvPy Dec 5, 2019

Choose a reason for hiding this comment

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

I did, sry :(
I made another PR with the fix, but it failed

I can make another PR with the fix + some other files from the list tonight, if you want

Ps: This is my first time contributing!

)
else:
self.colspecs = colspecs

if not isinstance(self.colspecs, (tuple, list)):
raise TypeError(
"column specifications must be a list or tuple, "
"input was a %r" % type(colspecs).__name__
f"column specifications must be a list or tuple, "
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
f"column specifications must be a list or tuple, "
"column specifications must be a list or tuple, "

The f prefix is only needed if actually substituting

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Noted. I'll change it tonight!

f"input was a {repr(type(colspecs).__name__)}"
Copy link
Contributor

Choose a reason for hiding this comment

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

you don't need any of the repr except for this one as they are all repr'ing strings.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I change the other strings to something like this?

f"input was a {(type(colspecs).name)}"

Copy link
Contributor

Choose a reason for hiding this comment

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

yesp (but you can leave anything that is not a string with repr(...), e.g. this one is a list

)

for colspec in self.colspecs:
Expand Down