|
1 | 1 | import datetime
|
2 | 2 | import json
|
3 |
| -import sys |
4 | 3 | from collections import deque
|
5 | 4 | from pathlib import Path
|
6 |
| -from typing import Any, Dict, Optional |
| 5 | +from typing import Annotated, Any, Dict, Optional |
| 6 | +from zoneinfo import ZoneInfo |
7 | 7 |
|
8 | 8 | import attrs
|
9 | 9 | import dateutil.tz
|
@@ -223,7 +223,8 @@ class MetadataLocalTime(Metadata):
|
223 | 223 |
|
224 | 224 | @attrs.define(kw_only=True)
|
225 | 225 | class ProductLocalTime(Product):
|
226 |
| - metadata: Optional[MetadataLocalTime] |
| 226 | + # in newer zyte-common-items this should inherit from ProductMetadata |
| 227 | + metadata: Optional[MetadataLocalTime] # type: ignore[assignment] |
227 | 228 |
|
228 | 229 |
|
229 | 230 | def _get_product_item(date: datetime.datetime) -> ProductLocalTime:
|
@@ -282,11 +283,6 @@ def test_pytest_frozen_time_naive(pytester, book_list_html_response) -> None:
|
282 | 283 | @pytest.mark.skipif(not time_machine.HAVE_TZSET, reason="Not supported on Windows")
|
283 | 284 | @pytest.mark.parametrize("offset", [-5, 0, 8])
|
284 | 285 | def test_pytest_frozen_time_tz(pytester, book_list_html_response, offset) -> None:
|
285 |
| - if sys.version_info >= (3, 9): |
286 |
| - from zoneinfo import ZoneInfo |
287 |
| - else: |
288 |
| - from backports.zoneinfo import ZoneInfo |
289 |
| - |
290 | 286 | tzinfo = ZoneInfo(f"Etc/GMT{-offset:+d}")
|
291 | 287 | frozen_time = datetime.datetime(2022, 3, 4, 20, 21, 22, tzinfo=tzinfo)
|
292 | 288 | _assert_frozen_item(frozen_time, pytester, book_list_html_response)
|
@@ -540,20 +536,14 @@ def test_page_object_exception_none(pytester, book_list_html_response) -> None:
|
540 | 536 | result.assert_outcomes(failed=1)
|
541 | 537 |
|
542 | 538 |
|
543 |
| -if sys.version_info >= (3, 9): |
544 |
| - from typing import Annotated |
545 |
| - |
546 |
| - @attrs.define(kw_only=True) |
547 |
| - class MyAnnotatedItemPage(MyItemPage): |
548 |
| - response: Annotated[HttpResponse, "foo", 42] |
| 539 | +@attrs.define(kw_only=True) |
| 540 | +class MyAnnotatedItemPage(MyItemPage): |
| 541 | + response: Annotated[HttpResponse, "foo", 42] |
549 | 542 |
|
550 |
| - async def to_item(self) -> dict: |
551 |
| - return {"foo": "bar"} |
| 543 | + async def to_item(self) -> dict: |
| 544 | + return {"foo": "bar"} |
552 | 545 |
|
553 | 546 |
|
554 |
| -@pytest.mark.skipif( |
555 |
| - sys.version_info < (3, 9), reason="No Annotated support in Python < 3.9" |
556 |
| -) |
557 | 547 | def test_annotated(pytester, book_list_html_response) -> None:
|
558 | 548 | _save_fixture(
|
559 | 549 | pytester,
|
|
0 commit comments