Skip to content

Commit b08c735

Browse files
authored
Merge pull request #225 from scrapy-plugins/modernize
Add Python 3.13, drop Python 3.8, update tool versions
2 parents 552020c + 43f8b0f commit b08c735

File tree

10 files changed

+37
-76
lines changed

10 files changed

+37
-76
lines changed

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Set up Python
1818
uses: actions/setup-python@v5
1919
with:
20-
python-version: '3.12'
20+
python-version: '3.13'
2121
- name: Install dependencies
2222
run: |
2323
python -m pip install --upgrade pip

.github/workflows/test.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,31 @@ jobs:
1717
fail-fast: false
1818
matrix:
1919
include:
20-
- python-version: '3.8'
20+
- python-version: '3.9'
2121
toxenv: pinned-scrapy-2x0
22-
- python-version: '3.8'
22+
- python-version: '3.9'
2323
toxenv: pinned-scrapy-2x1
24-
- python-version: '3.8'
24+
- python-version: '3.9'
2525
toxenv: pinned-scrapy-2x3
26-
- python-version: '3.8'
26+
- python-version: '3.9'
2727
toxenv: pinned-scrapy-2x4
28-
- python-version: '3.8'
28+
- python-version: '3.9'
2929
toxenv: pinned-scrapy-2x5
30-
- python-version: '3.8'
31-
toxenv: pinned-scrapy-2x6
3230
- python-version: '3.9'
31+
toxenv: pinned-scrapy-2x6
3332
- python-version: '3.10'
3433
- python-version: '3.11'
3534
- python-version: '3.12'
35+
- python-version: '3.13'
3636

37-
- python-version: '3.8'
37+
- python-version: '3.9'
3838
toxenv: pinned-provider
39-
- python-version: '3.12'
39+
- python-version: '3.13'
4040
toxenv: provider
4141

42-
- python-version: '3.8'
42+
- python-version: '3.9'
4343
toxenv: pinned-extra
44-
- python-version: '3.12'
44+
- python-version: '3.13'
4545
toxenv: extra
4646

4747
steps:
@@ -67,7 +67,7 @@ jobs:
6767
strategy:
6868
fail-fast: false
6969
matrix:
70-
python-version: ["3.12"]
70+
python-version: ["3.12"] # Keep in sync with .readthedocs.yml
7171
tox-job: ["mypy", "linters", "twine-check", "docs"]
7272

7373
steps:

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ repos:
44
hooks:
55
- id: isort
66
- repo: https://github.com/psf/black
7-
rev: 24.2.0
7+
rev: 24.10.0
88
hooks:
99
- id: black
1010
- repo: https://github.com/pycqa/flake8
11-
rev: 7.1.0
11+
rev: 7.1.1
1212
hooks:
1313
- id: flake8
1414
additional_dependencies:
1515
- flake8-docstrings
1616
- flake8-print
1717
- repo: https://github.com/adamchainz/blacken-docs
18-
rev: 1.16.0
18+
rev: 1.19.0
1919
hooks:
2020
- id: blacken-docs
2121
additional_dependencies:
22-
- black==24.2.0
22+
- black==24.10.0

.readthedocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ sphinx:
55
build:
66
os: ubuntu-22.04
77
tools:
8-
python: "3.11" # Keep in sync with .github/workflows/test.yml
8+
python: "3.12" # Keep in sync with .github/workflows/test.yml
99
python:
1010
install:
1111
- requirements: docs/requirements.txt

docs/setup.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ You need at least:
1818
- A :ref:`Zyte API <zyte-api>` subscription (there’s a :ref:`free trial
1919
<zapi-trial>`).
2020

21-
- Python 3.8+
21+
- Python 3.9+
2222

2323
- Scrapy 2.0.1+
2424

docs/usage/scrapy-poet.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ Dependency annotations
3939

4040
``ZyteApiProvider`` understands and makes use of some dependency annotations.
4141

42-
.. note:: Dependency annotations require Python 3.9+.
43-
4442
Item annotations
4543
----------------
4644

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tool.black]
2-
target-version = ["py38", "py39", "py310", "py311"]
2+
target-version = ["py39", "py310", "py311", "py312", "py313"]
33

44
[tool.isort]
55
profile = "black"

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ def get_version():
4343
"Natural Language :: English",
4444
"Operating System :: OS Independent",
4545
"Programming Language :: Python :: 3",
46-
"Programming Language :: Python :: 3.8",
4746
"Programming Language :: Python :: 3.9",
4847
"Programming Language :: Python :: 3.10",
4948
"Programming Language :: Python :: 3.11",
5049
"Programming Language :: Python :: 3.12",
50+
"Programming Language :: Python :: 3.13",
5151
],
5252
)

tests/test_providers.py

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import sys
21
from collections import defaultdict
2+
from typing import Annotated
33

44
import pytest
55

@@ -259,13 +259,8 @@ async def test_provider_params_remove_unused_options(mockserver):
259259
)
260260

261261

262-
@pytest.mark.skipif(
263-
sys.version_info < (3, 9), reason="No Annotated support in Python < 3.9"
264-
)
265262
@ensureDeferred
266263
async def test_provider_extractfrom(mockserver):
267-
from typing import Annotated
268-
269264
@attrs.define
270265
class AnnotatedProductPage(BasePage):
271266
product: Annotated[Product, ExtractFrom.httpResponseBody]
@@ -295,13 +290,8 @@ def parse_(self, response: DummyResponse, page: AnnotatedProductPage): # type:
295290
)
296291

297292

298-
@pytest.mark.skipif(
299-
sys.version_info < (3, 9), reason="No Annotated support in Python < 3.9"
300-
)
301293
@ensureDeferred
302294
async def test_provider_extractfrom_double(mockserver, caplog):
303-
from typing import Annotated
304-
305295
@attrs.define
306296
class AnnotatedProductPage(BasePage):
307297
product: Annotated[Product, ExtractFrom.httpResponseBody]
@@ -322,13 +312,8 @@ def parse_(self, response: DummyResponse, page: AnnotatedProductPage): # type:
322312
assert "Multiple different extractFrom specified for product" in caplog.text
323313

324314

325-
@pytest.mark.skipif(
326-
sys.version_info < (3, 9), reason="No Annotated support in Python < 3.9"
327-
)
328315
@ensureDeferred
329316
async def test_provider_extractfrom_override(mockserver):
330-
from typing import Annotated
331-
332317
@attrs.define
333318
class AnnotatedProductPage(BasePage):
334319
product: Annotated[Product, ExtractFrom.httpResponseBody]
@@ -359,13 +344,8 @@ def parse_(self, response: DummyResponse, page: AnnotatedProductPage): # type:
359344
)
360345

361346

362-
@pytest.mark.skipif(
363-
sys.version_info < (3, 9), reason="No Annotated support in Python < 3.9"
364-
)
365347
@ensureDeferred
366348
async def test_provider_geolocation(mockserver):
367-
from typing import Annotated
368-
369349
@attrs.define
370350
class GeoProductPage(BasePage):
371351
product: Product
@@ -385,9 +365,6 @@ def parse_(self, response: DummyResponse, page: GeoProductPage): # type: ignore
385365
assert item["product"].name == "Product name (country DE)"
386366

387367

388-
@pytest.mark.skipif(
389-
sys.version_info < (3, 9), reason="No Annotated support in Python < 3.9"
390-
)
391368
@ensureDeferred
392369
async def test_provider_geolocation_unannotated(mockserver, caplog):
393370
@attrs.define
@@ -414,9 +391,6 @@ def parse_(self, response: DummyResponse, page: GeoProductPage): # type: ignore
414391
}
415392

416393

417-
@pytest.mark.skipif(
418-
sys.version_info < (3, 9), reason="No Annotated support in Python < 3.9"
419-
)
420394
@pytest.mark.parametrize(
421395
"annotation",
422396
[
@@ -428,8 +402,6 @@ def parse_(self, response: DummyResponse, page: GeoProductPage): # type: ignore
428402
)
429403
@ensureDeferred
430404
async def test_provider_custom_attrs(mockserver, annotation):
431-
from typing import Annotated
432-
433405
@attrs.define
434406
class CustomAttrsPage(BasePage):
435407
product: Product
@@ -468,13 +440,8 @@ def parse_(self, response: DummyResponse, page: CustomAttrsPage): # type: ignor
468440
)
469441

470442

471-
@pytest.mark.skipif(
472-
sys.version_info < (3, 9), reason="No Annotated support in Python < 3.9"
473-
)
474443
@ensureDeferred
475444
async def test_provider_custom_attrs_values(mockserver):
476-
from typing import Annotated
477-
478445
@attrs.define
479446
class CustomAttrsPage(BasePage):
480447
product: Product
@@ -1086,13 +1053,8 @@ def parse_(self, response: DummyResponse, screenshot: Screenshot):
10861053
assert item["screenshot"].body == b"screenshot-body-contents"
10871054

10881055

1089-
@pytest.mark.skipif(
1090-
sys.version_info < (3, 9), reason="No Annotated support in Python < 3.9"
1091-
)
10921056
@ensureDeferred
10931057
async def test_provider_actions(mockserver, caplog):
1094-
from typing import Annotated
1095-
10961058
@attrs.define
10971059
class ActionProductPage(BasePage):
10981060
product: Product

tox.ini

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py38,py39,py310,py311,mypy,linters,twine-check,docs
2+
envlist = py39,py310,py311,py312,py313,mypy,linters,twine-check,docs
33

44
[testenv]
55
deps =
@@ -37,43 +37,43 @@ deps =
3737

3838
# Earliest supported Scrapy version.
3939
[testenv:pinned-scrapy-2x0]
40-
basepython=python3.8
40+
basepython=python3.9
4141
deps =
4242
{[pinned-pre-scrapy-2x5]deps}
4343
scrapy==2.0.1
4444

4545
# Scrapy version introducing Response.ip_address.
4646
[testenv:pinned-scrapy-2x1]
47-
basepython=python3.8
47+
basepython=python3.9
4848
deps =
4949
{[pinned-pre-scrapy-2x5]deps}
5050
scrapy==2.1.0
5151

5252
# Latest Scrapy version since 2.0.1 not requiring to install the reactor early.
5353
[testenv:pinned-scrapy-2x3]
54-
basepython=python3.8
54+
basepython=python3.9
5555
deps =
5656
{[pinned-pre-scrapy-2x5]deps}
5757
scrapy==2.3.0
5858

5959
# First Scrapy version requiring to install the reactor early.
6060
[testenv:pinned-scrapy-2x4]
61-
basepython=python3.8
61+
basepython=python3.9
6262
deps =
6363
{[pinned-pre-scrapy-2x5]deps}
6464
scrapy==2.4.0
6565

6666
# Scrapy version introducing Response.protocol.
6767
[testenv:pinned-scrapy-2x5]
68-
basepython=python3.8
68+
basepython=python3.9
6969
deps =
7070
{[pinned]deps}
7171
scrapy==2.5.0
7272

7373
# First Scrapy version since 2.4.0 where installing the reactor earlier is not
7474
# necessary.
7575
[testenv:pinned-scrapy-2x6]
76-
basepython=python3.8
76+
basepython=python3.9
7777
deps =
7878
{[pinned]deps}
7979
scrapy==2.6.0
@@ -82,7 +82,7 @@ deps =
8282
extras = provider
8383

8484
[testenv:pinned-provider]
85-
basepython=python3.8
85+
basepython=python3.9
8686
extras = provider
8787
deps =
8888
# scrapy-poet >= 0.4.0 depends on scrapy >= 2.6.0
@@ -93,14 +93,14 @@ deps =
9393
zyte-common-items==0.24.0
9494

9595
[testenv:pinned-extra]
96-
basepython=python3.8
96+
basepython=python3.9
9797
deps =
9898
{[testenv:pinned-scrapy-2x0]deps}
9999
scrapy-crawlera==1.1.0
100100
scrapy-zyte-smartproxy==2.0.0
101101

102102
[testenv:extra]
103-
basepython=python3.12
103+
basepython=python3.13
104104
deps =
105105
{[testenv]deps}
106106
scrapy-crawlera
@@ -109,8 +109,8 @@ deps =
109109
[testenv:mypy]
110110
extras = provider
111111
deps =
112-
mypy==1.8.0
113-
types-setuptools
112+
mypy==1.11.2
113+
pytest
114114

115115
commands = mypy scrapy_zyte_api tests
116116

@@ -120,9 +120,10 @@ commands = pre-commit run --all-files --show-diff-on-failure
120120

121121
[testenv:twine-check]
122122
deps =
123-
twine
123+
twine==5.1.1
124+
build==1.2.2
124125
commands =
125-
python setup.py sdist
126+
python -m build --sdist
126127
twine check dist/*
127128

128129
[testenv:docs]

0 commit comments

Comments
 (0)