diff --git a/tests/test_selector_csstranslator.py b/tests/test_selector_csstranslator.py index 80c6c39a..b3cdfa9a 100644 --- a/tests/test_selector_csstranslator.py +++ b/tests/test_selector_csstranslator.py @@ -2,7 +2,7 @@ Selector tests for cssselect backend """ import unittest -from typing import Any, Callable, List, Type, Protocol +from typing import Any, Callable, List, Type, Protocol, Tuple, Union import cssselect import pytest @@ -66,8 +66,9 @@ def assertEqual(self, first: Any, second: Any, msg: Any = ...) -> None: def assertRaises( self, - expected_exception: type[BaseException] - | tuple[type[BaseException], ...], + expected_exception: Union[ + Type[BaseException], Tuple[Type[BaseException], ...] + ], callable: Callable[..., object], *args: Any, **kwargs: Any, diff --git a/tests/typing/selector.py b/tests/typing/selector.py index 0db34541..b6f14345 100644 --- a/tests/typing/selector.py +++ b/tests/typing/selector.py @@ -1,5 +1,7 @@ # Basic usage of the Selector, strongly typed to test the typing of parsel's API. import re +from typing import List + from parsel import Selector @@ -8,9 +10,9 @@ def correct() -> None: text="" ) - li_values: list[str] = selector.css("li").getall() + li_values: List[str] = selector.css("li").getall() selector.re_first(re.compile(r"[32]"), "").strip() - xpath_values: list[str] = selector.xpath( + xpath_values: List[str] = selector.xpath( "//somens:a/text()", namespaces={"somens": "http://scrapy.org"} ).extract()