Skip to content

Commit

Permalink
Update Python versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
wRAR committed Oct 14, 2024
1 parent 4120db7 commit 39ef223
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
python-version: '3.13'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tests-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
env:
- TOXENV: py
include:
- python-version: '3.8'
- python-version: '3.9'
env:
TOXENV: pinned

Expand Down Expand Up @@ -48,7 +48,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.12']
python-version: ['3.13']
tox-job: ["mypy", "docs", "linters", "types", "twinecheck"]

steps:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
env:
- TOXENV: py
include:
- python-version: '3.8'
- python-version: '3.9'
env:
TOXENV: pinned

Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sphinx:
build:
os: ubuntu-22.04
tools:
python: "3.11" # Keep in sync with .github/workflows/tests-ubuntu.yml
python: "3.13" # Keep in sync with .github/workflows/tests-ubuntu.yml

python:
install:
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ web-poet

.. intro starts
``web-poet`` is a Python 3.8+ implementation of the `page object pattern`_ for
``web-poet`` is a Python 3.9+ implementation of the `page object pattern`_ for
web scraping. It enables writing portable, reusable web parsing code.

.. _page object pattern: https://martinfowler.com/bliki/PageObject.html
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"python-dateutil >= 2.7.0",
"time-machine >= 2.7.1",
"packaging >= 20.0",
"backports.zoneinfo >= 0.2.1; python_version < '3.9' and platform_system != 'Windows'",
],
classifiers=[
"Development Status :: 3 - Alpha",
Expand All @@ -39,10 +38,10 @@
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
],
)
11 changes: 1 addition & 10 deletions tests/test_serialization.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import sys
from typing import Type
from typing import Annotated, Type

import attrs
import pytest
Expand Down Expand Up @@ -218,12 +217,7 @@ def test_httpclient_empty(tmp_path) -> None:
assert "HttpClient" in read_serialized_deps


@pytest.mark.skipif(
sys.version_info < (3, 9), reason="No Annotated support in Python < 3.9"
)
def test_annotated(book_list_html_response) -> None:
from typing import Annotated

@attrs.define
class MyWebPage(ItemPage):
response: Annotated[HttpResponse, "foo", 42]
Expand All @@ -243,9 +237,6 @@ class MyWebPage(ItemPage):
_assert_pages_equal(po, deserialized_po)


@pytest.mark.skipif(
sys.version_info < (3, 9), reason="No Annotated support in Python < 3.9"
)
def test_annotated_duplicate(book_list_html_response) -> None:
url_str = "http://books.toscrape.com/index.html"
url = ResponseUrl(url_str)
Expand Down
25 changes: 7 additions & 18 deletions tests/test_testing.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import datetime
import json
import sys
from collections import deque
from pathlib import Path
from typing import Any, Dict, Optional
from typing import Annotated, Any, Dict, Optional
from zoneinfo import ZoneInfo

import attrs
import dateutil.tz
Expand Down Expand Up @@ -282,11 +282,6 @@ def test_pytest_frozen_time_naive(pytester, book_list_html_response) -> None:
@pytest.mark.skipif(not time_machine.HAVE_TZSET, reason="Not supported on Windows")
@pytest.mark.parametrize("offset", [-5, 0, 8])
def test_pytest_frozen_time_tz(pytester, book_list_html_response, offset) -> None:
if sys.version_info >= (3, 9):
from zoneinfo import ZoneInfo
else:
from backports.zoneinfo import ZoneInfo

tzinfo = ZoneInfo(f"Etc/GMT{-offset:+d}")
frozen_time = datetime.datetime(2022, 3, 4, 20, 21, 22, tzinfo=tzinfo)
_assert_frozen_item(frozen_time, pytester, book_list_html_response)
Expand Down Expand Up @@ -540,20 +535,14 @@ def test_page_object_exception_none(pytester, book_list_html_response) -> None:
result.assert_outcomes(failed=1)


if sys.version_info >= (3, 9):
from typing import Annotated

@attrs.define(kw_only=True)
class MyAnnotatedItemPage(MyItemPage):
response: Annotated[HttpResponse, "foo", 42]
@attrs.define(kw_only=True)
class MyAnnotatedItemPage(MyItemPage):
response: Annotated[HttpResponse, "foo", 42]

async def to_item(self) -> dict:
return {"foo": "bar"}
async def to_item(self) -> dict:
return {"foo": "bar"}


@pytest.mark.skipif(
sys.version_info < (3, 9), reason="No Annotated support in Python < 3.9"
)
def test_annotated(pytester, book_list_html_response) -> None:
_save_fixture(
pytester,
Expand Down
5 changes: 2 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py38,py39,py310,py311,py312,mypy,docs,types
envlist = py39,py310,py311,py312,py313,mypy,docs,types

[pytest]
asyncio_mode = strict
Expand Down Expand Up @@ -58,7 +58,7 @@ deps = -rrequirements-dev.txt
commands = pre-commit run --all-files --show-diff-on-failure

[testenv:pinned]
basepython = python3.8
basepython = python3.9
deps =
{[testenv]deps}
pytest==6.2.0
Expand All @@ -78,7 +78,6 @@ deps =
python-dateutil==2.7.0
time-machine==2.7.1
packaging==20.0
backports.zoneinfo==0.2.1 ; platform_system != 'Windows'


[testenv:twinecheck]
Expand Down
7 changes: 1 addition & 6 deletions web_poet/testing/fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import json
import logging
import os
import sys
from pathlib import Path
from typing import Any, Iterable, Optional, Type, TypeVar, Union, cast
from zoneinfo import ZoneInfo

import dateutil.parser
import dateutil.tz
Expand Down Expand Up @@ -181,11 +181,6 @@ def _parse_frozen_time(meta_value: str) -> datetime.datetime:
)
return parsed_value.astimezone()

if sys.version_info >= (3, 9):
from zoneinfo import ZoneInfo
else:
from backports.zoneinfo import ZoneInfo

if parsed_value.tzinfo == dateutil.tz.UTC:
return parsed_value.replace(tzinfo=ZoneInfo("UTC"))

Expand Down

0 comments on commit 39ef223

Please sign in to comment.