Skip to content

Commit

Permalink
Better typing fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
wRAR committed Oct 13, 2024
1 parent 844e37e commit e8c6890
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion parsel/csstranslator.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class TranslatorMixin:
"""

def xpath_element(self: TranslatorProtocol, selector: Element) -> XPathExpr:
# https://github.com/python/mypy/issues/12344
# https://github.com/python/mypy/issues/14757
xpath = super().xpath_element(selector) # type: ignore[safe-super]
return XPathExpr.from_xpath(xpath)

Expand Down
7 changes: 2 additions & 5 deletions parsel/selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
class CTGroupValue(TypedDict):
_parser: Union[Type[etree.XMLParser], Type[html.HTMLParser]]
_csstranslator: Union[GenericTranslator, HTMLTranslator]
_tostring_method: str
_tostring_method: _TostringMethodType


_ctgroup: Dict[str, CTGroupValue] = {
Expand Down Expand Up @@ -727,10 +727,7 @@ def get(self) -> Any:
try:
return etree.tostring(
self.root,
method=typing.cast(
"Literal['html', 'text', 'xml']",
_ctgroup[self.type]["_tostring_method"],
),
method=_ctgroup[self.type]["_tostring_method"],
encoding="unicode",
with_tail=False,
)
Expand Down

0 comments on commit e8c6890

Please sign in to comment.