Skip to content

Commit 13fd8ae

Browse files
committed
Update CI
1 parent 4b1dd41 commit 13fd8ae

File tree

7 files changed

+204
-81
lines changed

7 files changed

+204
-81
lines changed

.github/workflows/main.yml

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,37 @@
11
name: CI
2-
3-
on:
4-
push:
5-
branches: [ master ]
6-
pull_request:
7-
branches: [ master ]
8-
2+
on: [push, pull_request]
93
jobs:
10-
build:
11-
4+
test:
125
runs-on: ubuntu-latest
136
strategy:
147
fail-fast: false
158
matrix:
169
include:
10+
- python-version: "3.9"
11+
toxenv: min
1712
- python-version: "3.9"
1813
- python-version: "3.10"
1914
- python-version: "3.11"
2015
- python-version: "3.12"
2116
- python-version: "3.13"
22-
17+
- python-version: "3.13"
18+
toxenv: pre-commit
19+
- python-version: "3.13"
20+
toxenv: mypy
21+
- python-version: "3.13"
22+
toxenv: pylint
23+
- python-version: "3.13"
24+
toxenv: twinecheck
2325
steps:
24-
- uses: actions/checkout@v2
26+
- uses: actions/checkout@v4
2527
- name: libddb
2628
run: |
2729
sudo apt-get install libdb-dev
28-
2930
- name: Set up Python ${{ matrix.python-version }}
3031
uses: actions/setup-python@v5
3132
with:
3233
python-version: ${{ matrix.python-version }}
33-
- name: Cache pip
34-
uses: actions/cache@v2
35-
with:
36-
path: ~/.cache/pip
37-
key: ${{ runner.os}}-pip-${{ hashFiles('tests/requirements-test.txt') }}
38-
restore-keys: |
39-
${{ runner.os}}-pip-
40-
${{ runner.os}}-
41-
- name: Install dependencies
42-
run: |
43-
python -m pip install --upgrade pip
44-
pip install -r tests/requirements-test.txt
45-
- name: Test with pytest
34+
- name: Run
4635
run: |
47-
pytest
36+
pip install -U tox
37+
tox -e ${{ matrix.toxenv }}

pyproject.toml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,74 @@
1+
[tool.coverage.run]
2+
branch = true
3+
include = ["scrapy_deltafetch/*"]
4+
omit = ["tests/*"]
5+
disable_warnings = ["include-ignored"]
6+
7+
[tool.coverage.paths]
8+
source = [
9+
"scrapy_deltafetch",
10+
".tox/**/site-packages/scrapy-deltafetch"
11+
]
12+
13+
[tool.coverage.report]
14+
# https://github.com/nedbat/coveragepy/issues/831#issuecomment-517778185
15+
exclude_lines = ["pragma: no cover", "if TYPE_CHECKING:"]
16+
17+
18+
19+
[tool.pylint.MASTER]
20+
persistent = "no"
21+
jobs = 1 # >1 hides results
22+
23+
[tool.pylint."MESSAGES CONTROL"]
24+
enable = [
25+
"useless-suppression",
26+
]
27+
disable = [
28+
# Ones we want to ignore
29+
"attribute-defined-outside-init",
30+
"broad-exception-caught",
31+
"consider-using-with",
32+
"cyclic-import",
33+
"disallowed-name",
34+
"duplicate-code", # https://github.com/pylint-dev/pylint/issues/214
35+
"fixme",
36+
"import-outside-toplevel",
37+
"inherit-non-class", # false positives with create_deprecated_class()
38+
"invalid-name",
39+
"invalid-overridden-method",
40+
"isinstance-second-argument-not-valid-type", # false positives with create_deprecated_class()
41+
"line-too-long",
42+
"logging-format-interpolation",
43+
"logging-fstring-interpolation",
44+
"logging-not-lazy",
45+
"missing-docstring",
46+
"no-member",
47+
"no-name-in-module", # caught by mypy already
48+
"no-value-for-parameter", # https://github.com/pylint-dev/pylint/issues/3268
49+
"not-callable",
50+
"protected-access",
51+
"redefined-builtin",
52+
"redefined-outer-name",
53+
"too-few-public-methods",
54+
"too-many-ancestors",
55+
"too-many-arguments",
56+
"too-many-branches",
57+
"too-many-function-args",
58+
"too-many-instance-attributes",
59+
"too-many-lines",
60+
"too-many-locals",
61+
"too-many-positional-arguments",
62+
"too-many-public-methods",
63+
"too-many-return-statements",
64+
"unused-argument",
65+
"unused-import",
66+
"unused-variable",
67+
"useless-import-alias", # used as a hint to mypy
68+
"useless-return", # https://github.com/pylint-dev/pylint/issues/6530
69+
"wrong-import-position",
70+
]
71+
172
[tool.ruff.lint]
273
extend-select = [
374
# flake8-bugbear
@@ -103,3 +174,6 @@ ignore = [
103174
[tool.ruff.lint.per-file-ignores]
104175
# D102: Missing docstring in public method
105176
"tests/**" = ["D102"]
177+
178+
[tool.ruff.lint.pydocstyle]
179+
convention = "pep257"

requirements.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

scrapy_deltafetch/middleware.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from scrapy import signals
77
from scrapy.exceptions import NotConfigured
88
from scrapy.http import Request
9-
from scrapy.item import Item
109
from scrapy.utils.project import data_path
1110
from scrapy.utils.python import to_bytes
1211

@@ -36,6 +35,8 @@ def from_crawler(cls, crawler): # noqa: D102
3635
dir = data_path(s.get("DELTAFETCH_DIR", "deltafetch"))
3736
reset = s.getbool("DELTAFETCH_RESET")
3837
o = cls(dir, reset, crawler.stats)
38+
if o.stats is None:
39+
o.stats = crawler.stats
3940
crawler.signals.connect(o.spider_opened, signal=signals.spider_opened)
4041
crawler.signals.connect(o.spider_closed, signal=signals.spider_closed)
4142

@@ -56,14 +57,14 @@ def spider_opened(self, spider): # noqa: D102
5657
reset = self.reset or getattr(spider, "deltafetch_reset", False)
5758
flag = "n" if reset else "c"
5859
try:
59-
self.db = dbm.open(dbpath, flag=flag) # noqa: SIM115
60+
self.db = dbm.open(str(dbpath), flag=flag) # noqa: SIM115
6061
except Exception:
6162
logger.warning(
6263
f"Failed to open DeltaFetch database at {dbpath}, trying to recreate it"
6364
)
6465
if dbpath.exists():
6566
dbpath.unlink()
66-
self.db = dbm.open(dbpath, "c") # noqa: SIM115
67+
self.db = dbm.open(str(dbpath), "c") # noqa: SIM115
6768

6869
def spider_closed(self, spider): # noqa: D102
6970
self.db.close()
@@ -77,7 +78,7 @@ def process_spider_output(self, response, result, spider): # noqa: D102
7778
if self.stats:
7879
self.stats.inc_value("deltafetch/skipped", spider=spider)
7980
continue
80-
elif isinstance(r, (Item, dict)):
81+
else:
8182
key = self._get_key(response.request)
8283
self.db[key] = str(time.time())
8384
if self.stats:

tests/requirements-test.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)