-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Updated .format() to f-strings #30027
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
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -587,7 +587,7 @@ def _parse_tfoot_tr(self, table): | |
def _setup_build_doc(self): | ||
raw_text = _read(self.io) | ||
if not raw_text: | ||
raise ValueError("No text parsed from document: {doc}".format(doc=self.io)) | ||
raise ValueError(f"No text parsed from document: {self.io}") | ||
return raw_text | ||
|
||
def _build_doc(self): | ||
|
@@ -617,7 +617,7 @@ def _build_xpath_expr(attrs) -> str: | |
attrs["class"] = attrs.pop("class_") | ||
|
||
s = [f"@{k}={repr(v)}" for k, v in attrs.items()] | ||
return "[{expr}]".format(expr=" and ".join(s)) | ||
return f"[{' and '.join(s)}]" | ||
|
||
|
||
_re_namespace = {"re": "http://exslt.org/regular-expressions"} | ||
|
@@ -846,7 +846,7 @@ def _parser_dispatch(flavor): | |
|
||
|
||
def _print_as_set(s) -> str: | ||
return "{" + "{arg}".format(arg=", ".join(pprint_thing(el) for el in s)) + "}" | ||
return f"{{{', '.join(pprint_thing(el) for el in s)}}}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. join on previous line pls |
||
|
||
|
||
def _validate_flavor(flavor): | ||
|
@@ -871,10 +871,8 @@ def _validate_flavor(flavor): | |
|
||
if not flavor_set & valid_flavors: | ||
raise ValueError( | ||
"{invalid} is not a valid set of flavors, valid " | ||
"flavors are {valid}".format( | ||
invalid=_print_as_set(flavor_set), valid=_print_as_set(valid_flavors) | ||
) | ||
f"{_print_as_set(flavor_set)} is not a valid set of flavors, valid " | ||
f"flavors are {_print_as_set(valid_flavors)}" | ||
) | ||
return flavor | ||
|
||
|
@@ -898,11 +896,11 @@ def _parse(flavor, io, match, attrs, encoding, displayed_only, **kwargs): | |
elif hasattr(io, "seekable") and not io.seekable(): | ||
# if we couldn't rewind it, let the user know | ||
raise ValueError( | ||
"The flavor {} failed to parse your input. " | ||
f"The flavor {flav} failed to parse your input. " | ||
"Since you passed a non-rewindable file " | ||
"object, we can't rewind it to try " | ||
"another parser. Try read_html() with a " | ||
"different flavor.".format(flav) | ||
"different flavor." | ||
) | ||
|
||
retained = caught | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.