Skip to content

Commit 4e16a8c

Browse files
authored
Release notes for 0.29.0 (#255)
1 parent 861d597 commit 4e16a8c

19 files changed

+146
-164
lines changed

Diff for: .github/workflows/publish.yml

+15-24
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,23 @@
1-
# This workflows will upload a Python Package using Twine when a release is created
2-
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3-
4-
name: publish
5-
1+
name: Publish
62
on:
73
push:
84
tags:
9-
- "[0-9]+.[0-9]+.[0-9]+"
10-
5+
- '[0-9]+.[0-9]+.[0-9]+'
116
jobs:
12-
deploy:
7+
publish:
138
runs-on: ubuntu-latest
14-
9+
environment:
10+
name: pypi
11+
url: https://pypi.org/p/${{ github.event.repository.name }}
12+
permissions:
13+
id-token: write
1514
steps:
1615
- uses: actions/checkout@v4
17-
- name: Set up Python
18-
uses: actions/setup-python@v5
16+
- uses: actions/setup-python@v5
1917
with:
20-
python-version: '3.13'
21-
- name: Install dependencies
22-
run: |
23-
python -m pip install --upgrade pip
24-
pip install setuptools wheel twine
25-
- name: Build and publish
26-
if: startsWith(github.ref, 'refs/tags')
27-
env:
28-
TWINE_USERNAME: __token__
29-
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
30-
run: |
31-
python setup.py sdist bdist_wheel
32-
twine upload dist/*
18+
python-version: 3.13
19+
- run: |
20+
python -m pip install --upgrade build
21+
python -m build
22+
- name: Publish to PyPI
23+
uses: pypa/gh-action-pypi-publish@release/v1

Diff for: .github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ jobs:
7070
fail-fast: false
7171
matrix:
7272
python-version: ["3.12"] # Keep in sync with .readthedocs.yml
73-
tox-job: ["mypy", "linters", "twine-check", "docs"]
73+
tox-job: ["mypy", "pre-commit", "twine-check", "docs"]
7474

7575
steps:
7676
- uses: actions/checkout@v4

Diff for: .pre-commit-config.yaml

+6-15
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
11
repos:
2-
- repo: https://github.com/PyCQA/isort
3-
rev: 5.13.2
4-
hooks:
5-
- id: isort
6-
- repo: https://github.com/psf/black
7-
rev: 24.10.0
8-
hooks:
9-
- id: black
10-
- repo: https://github.com/pycqa/flake8
11-
rev: 7.1.1
12-
hooks:
13-
- id: flake8
14-
additional_dependencies:
15-
- flake8-docstrings
16-
- flake8-print
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.11.0
4+
hooks:
5+
- id: ruff
6+
args: [ --fix ]
7+
- id: ruff-format
178
- repo: https://github.com/adamchainz/blacken-docs
189
rev: 1.19.0
1910
hooks:

Diff for: CHANGES.rst

+18
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
Changes
22
=======
33

4+
0.29.0 (unreleased)
5+
-------------------
6+
7+
- Improve the removal and mapping of proxy headers accidentally included in
8+
requests:
9+
10+
- Remove or map :ref:`Zyte API proxy mode headers <zapi-proxy-headers>`
11+
(``Zyte-…``), not only :ref:`Smart Proxy Manager headers
12+
<spm-request-headers>` (``X-Crawlera-…``).
13+
14+
- Remove or map headers defined through
15+
:http:`request:customHttpRequestHeaders`, not only those defined in
16+
:attr:`Request.headers <scrapy.http.Request.headers>`.
17+
18+
- Support :meth:`~scrapy.Spider.start_requests` yielding items, which is
19+
possible since Scrapy 2.12.
20+
21+
422
0.28.0 (2025-02-18)
523
-------------------
624

Diff for: pyproject.toml

+52-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,47 @@
1-
[tool.black]
2-
target-version = ["py39", "py310", "py311", "py312", "py313"]
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "scrapy-zyte-api"
7+
version = "0.28.0"
8+
description = "Client library to process URLs through Zyte API"
9+
authors = [{name = "Zyte Group Ltd", email = "[email protected]"}]
10+
license = "BSD-3-Clause"
11+
readme = "README.rst"
12+
classifiers = [
13+
"Development Status :: 4 - Beta",
14+
"Intended Audience :: Developers",
15+
"Natural Language :: English",
16+
"Operating System :: OS Independent",
17+
"Programming Language :: Python",
18+
"Programming Language :: Python :: 3",
19+
"Programming Language :: Python :: 3.9",
20+
"Programming Language :: Python :: 3.10",
21+
"Programming Language :: Python :: 3.11",
22+
"Programming Language :: Python :: 3.12",
23+
"Programming Language :: Python :: 3.13",
24+
]
25+
requires-python = ">=3.9"
26+
# Sync with [pinned] @ tox.ini
27+
dependencies = [
28+
"packaging>=20.0",
29+
"scrapy>=2.0.1",
30+
"zyte-api>=0.5.1",
31+
]
32+
33+
[project.optional-dependencies]
34+
# Sync with [testenv:pinned-provider] @ tox.ini
35+
provider = [
36+
"andi>=0.6.0",
37+
"scrapy-poet>=0.22.3",
38+
"web-poet>=0.17.0",
39+
"zyte-common-items>=0.27.0",
40+
]
41+
42+
[project.urls]
43+
source = "https://github.com/scrapy-plugins/scrapy-zyte-api"
44+
docs = "https://scrapy-zyte-api.readthedocs.io/en/latest/"
345

446
[tool.bumpversion]
547
current_version = "0.28.0"
@@ -16,12 +58,17 @@ regex = true
1658
[[tool.bumpversion.files]]
1759
filename = "docs/conf.py"
1860

61+
[[tool.bumpversion.files]]
62+
filename = "pyproject.toml"
63+
parse = "version\\s*=\\s*['\"](?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
64+
1965
[[tool.bumpversion.files]]
2066
filename = "scrapy_zyte_api/__version__.py"
2167

22-
[tool.isort]
23-
profile = "black"
24-
multi_line_output = 3
68+
[tool.hatch.build.targets.sdist]
69+
include = [
70+
"scrapy_zyte_api/*.py",
71+
]
2572

2673
[tool.mypy]
2774
check_untyped_defs = true

Diff for: requirements-dev.txt

-1
This file was deleted.

Diff for: scrapy_zyte_api/__init__.py

+24
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,27 @@
4646
#: Instance of :class:`web_poet.rules.RulesRegistry` that holds :ref:`session
4747
#: configs <session-configs>`.
4848
session_config_registry = _session_config_registry
49+
50+
__all__ = [
51+
"ExtractFrom",
52+
"Actions",
53+
"Geolocation",
54+
"Screenshot",
55+
"ScrapyZyteAPIDownloadHandler",
56+
"ScrapyZyteAPIRequestFingerprinter",
57+
"ScrapyZyteAPIDownloaderMiddleware",
58+
"ScrapyZyteAPIRefererSpiderMiddleware",
59+
"ScrapyZyteAPISpiderMiddleware",
60+
"ScrapyZyteAPISessionDownloaderMiddleware",
61+
"Addon",
62+
"actions",
63+
"custom_attrs",
64+
"get_request_session_id",
65+
"is_session_init_request",
66+
"session_config",
67+
"session_config_registry",
68+
"LocationSessionConfig",
69+
"SessionConfig",
70+
"SESSION_DEFAULT_RETRY_POLICY",
71+
"SESSION_AGGRESSIVE_RETRY_POLICY",
72+
]

Diff for: scrapy_zyte_api/_annotations.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ class ExtractFrom(str, Enum):
1111
See :ref:`annotations`.
1212
"""
1313

14-
httpResponseBody: str = "httpResponseBody"
15-
browserHtml: str = "browserHtml"
14+
httpResponseBody = "httpResponseBody"
15+
browserHtml = "browserHtml"
1616

1717

1818
class _Selector(TypedDict, total=False):

Diff for: scrapy_zyte_api/_middlewares.py

-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ async def process_spider_output_async(self, response, result, spider):
209209

210210

211211
class ScrapyZyteAPIRefererSpiderMiddleware:
212-
213212
@classmethod
214213
def from_crawler(cls, crawler):
215214
return cls(crawler)

Diff for: scrapy_zyte_api/_params.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ def _set_http_response_headers_from_request(
744744
api_params.setdefault("httpResponseHeaders", True)
745745
elif (
746746
api_params.get("httpResponseHeaders") is False
747-
and not default_params.get("httpResponseHeaders") is False
747+
and default_params.get("httpResponseHeaders") is not False
748748
):
749749
logger.warning(
750750
"You do not need to set httpResponseHeaders to False if "

Diff for: scrapy_zyte_api/_session.py

+5-10
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@ def get_retry_request( # type: ignore[misc]
121121
return new_request
122122
stats.inc_value(f"{stats_base_key}/max_reached")
123123
logger.error(
124-
"Gave up retrying %(request)s (failed %(retry_times)d times): "
125-
"%(reason)s",
124+
"Gave up retrying %(request)s (failed %(retry_times)d times): %(reason)s",
126125
{"request": request, "retry_times": retry_times, "reason": reason},
127126
extra={"spider": spider},
128127
)
@@ -453,7 +452,6 @@ def check(self, response: Response, request: Request) -> bool:
453452
except ImportError:
454453

455454
class SessionConfigRulesRegistry:
456-
457455
def session_config_cls(self, request: Request) -> Type[SessionConfig]:
458456
return SessionConfig
459457

@@ -522,8 +520,7 @@ def check(self, response: Response, request: Request) -> bool:
522520
and session configs are registered in their own rule registry.
523521
"""
524522
raise RuntimeError(
525-
"To use the @session_config decorator you first must install "
526-
"web-poet."
523+
"To use the @session_config decorator you first must install web-poet."
527524
)
528525

529526
else:
@@ -532,14 +529,15 @@ def check(self, response: Response, request: Request) -> bool:
532529
from web_poet.rules import Strings
533530

534531
class SessionConfigRulesRegistry(RulesRegistry): # type: ignore[no-redef]
535-
536532
def __init__(self):
537533
rules = [ApplyRule(for_patterns=Patterns(include=[""]), use=SessionConfig)] # type: ignore[arg-type]
538534
super().__init__(rules=rules)
539535

540536
def session_config_cls(self, request: Request) -> Type[SessionConfig]:
541537
cls = SessionConfig
542-
overrides: Dict[Type[SessionConfig], Type[SessionConfig]] = self.overrides_for(request.url) # type: ignore[assignment]
538+
overrides: Dict[Type[SessionConfig], Type[SessionConfig]] = (
539+
self.overrides_for(request.url) # type: ignore[assignment]
540+
)
543541
while cls in overrides:
544542
cls = overrides[cls]
545543
return cls
@@ -563,7 +561,6 @@ def session_config(
563561

564562

565563
class FatalErrorHandler:
566-
567564
def __init__(self, crawler):
568565
self.crawler = crawler
569566

@@ -593,7 +590,6 @@ def __exit__(self, exc_type, exc, tb):
593590

594591

595592
class _SessionManager:
596-
597593
def __init__(self, crawler: Crawler):
598594
self._crawler = crawler
599595

@@ -992,7 +988,6 @@ def handle_expiration(self, request: Request):
992988

993989

994990
class ScrapyZyteAPISessionDownloaderMiddleware:
995-
996991
@classmethod
997992
def from_crawler(cls, crawler: Crawler):
998993
return cls(crawler)

Diff for: scrapy_zyte_api/addon.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,12 @@ def update_settings(self, settings: BaseSettings) -> None:
8888
"addon",
8989
)
9090

91-
settings["DOWNLOAD_HANDLERS"][
92-
"http"
93-
] = "scrapy_zyte_api.handler.ScrapyZyteAPIHTTPDownloadHandler"
94-
settings["DOWNLOAD_HANDLERS"][
95-
"https"
96-
] = "scrapy_zyte_api.handler.ScrapyZyteAPIHTTPSDownloadHandler"
91+
settings["DOWNLOAD_HANDLERS"]["http"] = (
92+
"scrapy_zyte_api.handler.ScrapyZyteAPIHTTPDownloadHandler"
93+
)
94+
settings["DOWNLOAD_HANDLERS"]["https"] = (
95+
"scrapy_zyte_api.handler.ScrapyZyteAPIHTTPSDownloadHandler"
96+
)
9797
_setdefault(
9898
settings, "DOWNLOADER_MIDDLEWARES", ScrapyZyteAPIDownloaderMiddleware, 633
9999
)

Diff for: setup.cfg

-8
This file was deleted.

Diff for: setup.py

-52
This file was deleted.

0 commit comments

Comments
 (0)