File tree Expand file tree Collapse file tree 1 file changed +12
-10
lines changed
Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change 88 Any ,
99 Dict ,
1010 List ,
11+ Literal ,
1112 Mapping ,
1213 Optional ,
1314 Pattern ,
3233
3334_SelectorType = TypeVar ("_SelectorType" , bound = "Selector" )
3435_ParserType = Union [etree .XMLParser , etree .HTMLParser ]
36+ _TostringMethodType = Literal [ # simplified _OutputMethodArg from types-lxml
37+ "html" ,
38+ "xml" ,
39+ ]
3540
3641lxml_version = parse_version (etree .__version__ )
3742lxml_huge_tree_version = parse_version ("4.2" )
@@ -341,8 +346,8 @@ def __init__(
341346 self ._csstranslator : OriginalGenericTranslator = typing .cast (
342347 OriginalGenericTranslator , _ctgroup [st ]["_csstranslator" ]
343348 )
344- self ._tostring_method : str = typing .cast (
345- str , _ctgroup [st ]["_tostring_method" ]
349+ self ._tostring_method : _TostringMethodType = typing .cast (
350+ _TostringMethodType , _ctgroup [st ]["_tostring_method" ]
346351 )
347352
348353 if text is not None :
@@ -508,14 +513,11 @@ def get(self) -> str:
508513 Percent encoded content is unquoted.
509514 """
510515 try :
511- return typing .cast (
512- str ,
513- etree .tostring (
514- self .root ,
515- method = self ._tostring_method ,
516- encoding = "unicode" ,
517- with_tail = False ,
518- ),
516+ return etree .tostring (
517+ self .root ,
518+ method = self ._tostring_method ,
519+ encoding = "unicode" ,
520+ with_tail = False ,
519521 )
520522 except (AttributeError , TypeError ):
521523 if self .root is True :
You can’t perform that action at this time.
0 commit comments