@@ -587,7 +587,7 @@ def _parse_tfoot_tr(self, table):
587587 def _setup_build_doc (self ):
588588 raw_text = _read (self .io )
589589 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 } " )
591591 return raw_text
592592
593593 def _build_doc (self ):
@@ -616,8 +616,8 @@ def _build_xpath_expr(attrs) -> str:
616616 if "class_" in attrs :
617617 attrs ["class" ] = attrs .pop ("class_" )
618618
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 } ]"
621621
622622
623623_re_namespace = {"re" : "http://exslt.org/regular-expressions" }
@@ -846,7 +846,8 @@ def _parser_dispatch(flavor):
846846
847847
848848def _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 } }}"
850851
851852
852853def _validate_flavor (flavor ):
@@ -871,10 +872,8 @@ def _validate_flavor(flavor):
871872
872873 if not flavor_set & valid_flavors :
873874 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 )} "
878877 )
879878 return flavor
880879
@@ -898,11 +897,11 @@ def _parse(flavor, io, match, attrs, encoding, displayed_only, **kwargs):
898897 elif hasattr (io , "seekable" ) and not io .seekable ():
899898 # if we couldn't rewind it, let the user know
900899 raise ValueError (
901- "The flavor {} failed to parse your input. "
900+ f "The flavor { flav } failed to parse your input. "
902901 "Since you passed a non-rewindable file "
903902 "object, we can't rewind it to try "
904903 "another parser. Try read_html() with a "
905- "different flavor." . format ( flav )
904+ "different flavor."
906905 )
907906
908907 retained = caught
0 commit comments