@@ -587,7 +587,7 @@ def _parse_tfoot_tr(self, table):
587
587
def _setup_build_doc (self ):
588
588
raw_text = _read (self .io )
589
589
if not raw_text :
590
- raise ValueError ("No text parsed from document: {doc}" . format ( doc = self .io ) )
590
+ raise ValueError (f "No text parsed from document: { self .io } " )
591
591
return raw_text
592
592
593
593
def _build_doc (self ):
@@ -616,8 +616,8 @@ def _build_xpath_expr(attrs) -> str:
616
616
if "class_" in attrs :
617
617
attrs ["class" ] = attrs .pop ("class_" )
618
618
619
- s = [f"@{ k } ={ repr (v )} " for k , v in attrs .items ()]
620
- return "[{expr }]" . format ( expr = " and " . join ( s ))
619
+ s = " and " . join ( [f"@{ k } ={ repr (v )} " for k , v in attrs .items ()])
620
+ return f "[{ s } ]"
621
621
622
622
623
623
_re_namespace = {"re" : "http://exslt.org/regular-expressions" }
@@ -846,7 +846,8 @@ def _parser_dispatch(flavor):
846
846
847
847
848
848
def _print_as_set (s ) -> str :
849
- return "{" + "{arg}" .format (arg = ", " .join (pprint_thing (el ) for el in s )) + "}"
849
+ arg = ", " .join (pprint_thing (el ) for el in s )
850
+ return f"{{{ arg } }}"
850
851
851
852
852
853
def _validate_flavor (flavor ):
@@ -871,10 +872,8 @@ def _validate_flavor(flavor):
871
872
872
873
if not flavor_set & valid_flavors :
873
874
raise ValueError (
874
- "{invalid} is not a valid set of flavors, valid "
875
- "flavors are {valid}" .format (
876
- invalid = _print_as_set (flavor_set ), valid = _print_as_set (valid_flavors )
877
- )
875
+ f"{ _print_as_set (flavor_set )} is not a valid set of flavors, valid "
876
+ f"flavors are { _print_as_set (valid_flavors )} "
878
877
)
879
878
return flavor
880
879
@@ -898,11 +897,11 @@ def _parse(flavor, io, match, attrs, encoding, displayed_only, **kwargs):
898
897
elif hasattr (io , "seekable" ) and not io .seekable ():
899
898
# if we couldn't rewind it, let the user know
900
899
raise ValueError (
901
- "The flavor {} failed to parse your input. "
900
+ f "The flavor { flav } failed to parse your input. "
902
901
"Since you passed a non-rewindable file "
903
902
"object, we can't rewind it to try "
904
903
"another parser. Try read_html() with a "
905
- "different flavor." . format ( flav )
904
+ "different flavor."
906
905
)
907
906
908
907
retained = caught
0 commit comments