Skip to content

Commit 5c69dbd

Browse files
authored
Merge pull request #92 from zytedata/improve-typing
Improve typing, add py.typed, bump ruff
2 parents 9c09ebc + cbbc848 commit 5c69dbd

32 files changed

+371
-237
lines changed

.github/workflows/publish.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,12 @@ jobs:
1212
permissions:
1313
id-token: write
1414
steps:
15-
- uses: actions/checkout@v4
16-
- uses: actions/setup-python@v5
15+
- uses: actions/checkout@v5
16+
- uses: actions/setup-python@v6
1717
with:
1818
python-version: 3.13
1919
- run: |
2020
python -m pip install --upgrade build
2121
python -m build
2222
- name: Publish to PyPI
2323
uses: pypa/gh-action-pypi-publish@release/v1
24-
with:
25-
password: ${{ secrets.PYPI_TOKEN }}

.github/workflows/test.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ jobs:
3030
tox: x402
3131

3232
steps:
33-
- uses: actions/checkout@v4
33+
- uses: actions/checkout@v5
3434
- name: Set up Python ${{ matrix.python-version }}
35-
uses: actions/setup-python@v5
35+
uses: actions/setup-python@v6
3636
with:
3737
python-version: ${{ matrix.python-version }}
3838
- name: Install dependencies
@@ -44,7 +44,7 @@ jobs:
4444
tox -e ${{ matrix.tox || 'py' }}
4545
- name: coverage
4646
if: ${{ success() }}
47-
uses: codecov/codecov-action@v4.0.1
47+
uses: codecov/codecov-action@v5
4848
with:
4949
token: ${{ secrets.CODECOV_TOKEN }}
5050

@@ -53,13 +53,13 @@ jobs:
5353
strategy:
5454
fail-fast: false
5555
matrix:
56-
python-version: ['3.12'] # Keep in sync with .readthedocs.yml
56+
python-version: ["3.13"] # Keep in sync with .readthedocs.yml
5757
tox-job: ["mypy", "docs"]
5858

5959
steps:
60-
- uses: actions/checkout@v4
60+
- uses: actions/checkout@v5
6161
- name: Set up Python ${{ matrix.python-version }}
62-
uses: actions/setup-python@v5
62+
uses: actions/setup-python@v6
6363
with:
6464
python-version: ${{ matrix.python-version }}
6565
- name: Install dependencies

.pre-commit-config.yaml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.9.6
3+
rev: v0.13.3
44
hooks:
5-
- id: ruff
5+
- id: ruff-check
66
args: [ --fix ]
77
- id: ruff-format
88
- repo: https://github.com/adamchainz/blacken-docs
9-
rev: 1.19.0
9+
rev: 1.20.0
1010
hooks:
1111
- id: blacken-docs
1212
additional_dependencies:
13-
- black==25.1.0
13+
- black==25.9.0
14+
- repo: https://github.com/pre-commit/pre-commit-hooks
15+
rev: v6.0.0
16+
hooks:
17+
- id: end-of-file-fixer
18+
- id: trailing-whitespace
19+
- repo: https://github.com/sphinx-contrib/sphinx-lint
20+
rev: v1.0.0
21+
hooks:
22+
- id: sphinx-lint

.readthedocs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ formats: all
33
sphinx:
44
configuration: docs/conf.py
55
build:
6-
os: ubuntu-22.04
6+
os: ubuntu-24.04
77
tools:
88
# For available versions, see:
99
# https://docs.readthedocs.io/en/stable/config-file/v2.html#build-tools-python
10-
python: "3.12" # Keep in sync with .github/workflows/test.yml
10+
python: "3.13" # Keep in sync with .github/workflows/test.yml
1111
python:
1212
install:
1313
- requirements: docs/requirements.txt

docs/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ help:
1616
# Catch-all target: route all unknown targets to Sphinx using the new
1717
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
1818
%: Makefile
19-
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
19+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# -- Project information -----------------------------------------------------
1717

1818
project = "python-zyte-api"
19-
copyright = "2021, Zyte Group Ltd"
19+
project_copyright = "2021, Zyte Group Ltd"
2020
author = "Zyte Group Ltd"
2121

2222
# The short X.Y version

docs/use/x402.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
x402
55
====
66

7-
It is possible to use :ref:`Zyte API <zyte-api>` without a Zyte API account by
7+
It is possible to use :ref:`Zyte API <zyte-api>` without a Zyte API account by
88
using the x402_ protocol to handle payments:
99

1010
#. Read the `Zyte Terms of Service`_. By using Zyte API, you are accepting

pyproject.toml

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,39 @@ filename = "zyte_api/__version__.py"
2121

2222
[tool.coverage.run]
2323
branch = true
24-
25-
[tool.coverage.report]
26-
exclude_also = [
27-
"if TYPE_CHECKING:",
24+
patch = [
25+
"subprocess",
2826
]
2927

28+
[tool.mypy]
29+
allow_untyped_defs = false
30+
implicit_reexport = false
31+
32+
[[tool.mypy.overrides]]
33+
module = "runstats"
34+
ignore_missing_imports = true
35+
36+
[[tool.mypy.overrides]]
37+
module = "tests.*"
38+
allow_untyped_defs = true
39+
3040
[tool.pytest.ini_options]
3141
filterwarnings = [
3242
"ignore:The zyte_api\\.aio module is deprecated:DeprecationWarning"
3343
]
3444

3545
[tool.ruff.lint]
3646
extend-select = [
47+
# flake8-builtins
48+
"A",
49+
# flake8-async
50+
"ASYNC",
3751
# flake8-bugbear
3852
"B",
3953
# flake8-comprehensions
4054
"C4",
55+
# flake8-commas
56+
"COM",
4157
# pydocstyle
4258
"D",
4359
# flake8-future-annotations
@@ -84,6 +100,8 @@ extend-select = [
84100
"T10",
85101
# flake8-type-checking
86102
"TC",
103+
# flake8-tidy-imports
104+
"TID",
87105
# pyupgrade
88106
"UP",
89107
# pycodestyle warnings
@@ -92,6 +110,8 @@ extend-select = [
92110
"YTT",
93111
]
94112
ignore = [
113+
# Trailing comma missing
114+
"COM812",
95115
# Missing docstring in public module
96116
"D100",
97117
# Missing docstring in public class
@@ -144,21 +164,27 @@ ignore = [
144164
"S101",
145165
]
146166

167+
[tool.ruff.lint.flake8-pytest-style]
168+
parametrize-values-type = "tuple"
169+
170+
[tool.ruff.lint.flake8-tidy-imports]
171+
banned-module-level-imports = ["twisted.internet.reactor"]
172+
173+
[tool.ruff.lint.flake8-type-checking]
174+
runtime-evaluated-decorators = ["attr.s"]
175+
176+
[tool.ruff.lint.isort]
177+
split-on-trailing-comma = false
178+
147179
[tool.ruff.lint.per-file-ignores]
148180
"zyte_api/__init__.py" = ["F401"]
149181
"zyte_api/aio/errors.py" = ["F401"]
150182
"zyte_api/aio/retry.py" = ["F401"]
151183
"tests/*" = ["S"]
152184
"docs/**" = ["B006"]
153185
# Skip PEP 604 suggestions for files with attr classes
154-
"zyte_api/errors.py" = ["UP007"]
155-
"zyte_api/stats.py" = ["UP007"]
156-
157-
[tool.ruff.lint.flake8-pytest-style]
158-
parametrize-values-type = "tuple"
159-
160-
[tool.ruff.lint.flake8-type-checking]
161-
runtime-evaluated-decorators = ["attr.s"]
186+
"zyte_api/errors.py" = ["UP007", "UP045"]
187+
"zyte_api/stats.py" = ["UP007", "UP045"]
162188

163189
[tool.ruff.lint.pydocstyle]
164190
convention = "pep257"

setup.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
author_email="[email protected]",
1313
url="https://github.com/zytedata/python-zyte-api",
1414
packages=find_packages(exclude=["tests", "examples"]),
15+
package_data={
16+
"zyte_api": ["py.typed"],
17+
},
18+
include_package_data=True,
1519
entry_points={
1620
"console_scripts": ["zyte-api=zyte_api.__main__:_main"],
1721
},

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
@pytest.fixture(scope="session")
55
def mockserver():
6-
from .mockserver import MockServer
6+
from .mockserver import MockServer # noqa: PLC0415
77

88
with MockServer() as server:
99
yield server

0 commit comments

Comments
 (0)