Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernize #52

Merged
merged 18 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .bumpversion.cfg

This file was deleted.

3 changes: 0 additions & 3 deletions .coveragerc

This file was deleted.

49 changes: 25 additions & 24 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,42 @@
name: CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.5, 3.6, 3.7, 3.8, 3.9]

include:
- python-version: "3.9"
toxenv: min
- python-version: "3.9"
- python-version: "3.10"
- python-version: "3.11"
- python-version: "3.12"
- python-version: "3.13"
- python-version: "3.13"
toxenv: pre-commit
- python-version: "3.13"
toxenv: mypy
- python-version: "3.13"
toxenv: pylint
- python-version: "3.13"
toxenv: twinecheck
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: libddb
run: |
sudo apt-get install libdb-dev

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os}}-pip-${{ hashFiles('tests/requirements-test.txt') }}
restore-keys: |
${{ runner.os}}-pip-
${{ runner.os}}-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r tests/requirements-test.txt
- name: Test with pytest
- name: Run
env:
TOXENV: ${{ matrix.toxenv }}
run: |
pytest
pip install -U tox
tox
42 changes: 19 additions & 23 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
name: Upload Python Package

name: Publish
on:
release:
types: [created]

push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
jobs:
deploy:
publish:
runs-on: ubuntu-latest

environment:
name: pypi
url: https://pypi.org/p/${{ github.event.repository.name }}
permissions:
id-token: write
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.13
- run: |
python -m pip install --upgrade build
python -m build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.7
hooks:
- id: ruff
args: [ --fix ]
- id: ruff-format
10 changes: 10 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
Changes
=======

2.1.0 (unreleased)
------------------

* Drop support for Python 3.8 and lower, add support for Python 3.9 and higher.
* Add support for Scrapy 2.12.
* Use the ``REQUEST_FINGERPRINTER_CLASS`` setting introduced in Scrapy 2.7.
* Support new item types introduced in Scrapy 2.2.
* Support ``Path`` instances in the ``DELTAFETCH_DIR`` setting.

2.0.0 (2021-09-20)
------------------
* drop Python 2 support
Expand Down
228 changes: 228 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
[build-system]
requires = ["setuptools>=61.2"]
build-backend = "setuptools.build_meta"

[project]
name = "scrapy-deltafetch"
version = "2.0.1"
authors = [{name = "Zyte", email = "opensource@zyte.com"}]
license = {text = "BSD"}
description = "Scrapy middleware to ignore previously crawled pages"
readme = "README.rst"
classifiers = [
"Development Status :: 4 - Beta",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"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",
]
requires-python = ">=3.9"
dependencies = ["Scrapy>=1.1.0"]

[project.urls]
Homepage = "http://github.com/scrapy-plugins/scrapy-deltafetch"

[tool.bumpversion]
current_version = "2.0.1"
commit = true
tag = true

[[tool.bumpversion.files]]
filename = 'CHANGES.rst'
search = "\\(unreleased\\)$"
replace = "({now:%Y-%m-%d})"
regex = true

[[tool.bumpversion.files]]
search = "version = \"{current_version}\""
replace = "version = \"{new_version}\""
filename = "pyproject.toml"

[[tool.bumpversion.files]]
filename = "scrapy_deltafetch/__init__.py"

[tool.coverage.run]
branch = true
include = ["scrapy_deltafetch/*"]
omit = ["tests/*"]
disable_warnings = ["include-ignored"]

[tool.coverage.paths]
source = [
"scrapy_deltafetch",
".tox/**/site-packages/scrapy-deltafetch"
]

[tool.coverage.report]
# https://github.com/nedbat/coveragepy/issues/831#issuecomment-517778185
exclude_lines = ["pragma: no cover", "if TYPE_CHECKING:"]

[tool.pylint.MASTER]
persistent = "no"
jobs = 1 # >1 hides results

[tool.pylint."MESSAGES CONTROL"]
enable = [
"useless-suppression",
]
disable = [
# Ones we want to ignore
"attribute-defined-outside-init",
"broad-exception-caught",
"consider-using-with",
"cyclic-import",
"disallowed-name",
"duplicate-code", # https://github.com/pylint-dev/pylint/issues/214
"fixme",
"import-outside-toplevel",
"inherit-non-class", # false positives with create_deprecated_class()
"invalid-name",
"invalid-overridden-method",
"isinstance-second-argument-not-valid-type", # false positives with create_deprecated_class()
"line-too-long",
"logging-format-interpolation",
"logging-fstring-interpolation",
"logging-not-lazy",
"missing-docstring",
"no-member",
"no-name-in-module", # caught by mypy already
"no-value-for-parameter", # https://github.com/pylint-dev/pylint/issues/3268
"not-callable",
"protected-access",
"redefined-builtin",
"redefined-outer-name",
"too-few-public-methods",
"too-many-ancestors",
"too-many-arguments",
"too-many-branches",
"too-many-function-args",
"too-many-instance-attributes",
"too-many-lines",
"too-many-locals",
"too-many-positional-arguments",
"too-many-public-methods",
"too-many-return-statements",
"unused-argument",
"unused-import",
"unused-variable",
"useless-import-alias", # used as a hint to mypy
"useless-return", # https://github.com/pylint-dev/pylint/issues/6530
"wrong-import-position",
]

[tool.ruff.lint]
extend-select = [
# flake8-bugbear
"B",
# flake8-comprehensions
"C4",
# pydocstyle
"D",
# flake8-future-annotations
"FA",
# flynt
"FLY",
# refurb
"FURB",
# isort
"I",
# flake8-implicit-str-concat
"ISC",
# flake8-logging
"LOG",
# Perflint
"PERF",
# pygrep-hooks
"PGH",
# flake8-pie
"PIE",
# pylint
"PL",
# flake8-pytest-style
"PT",
# flake8-use-pathlib
"PTH",
# flake8-pyi
"PYI",
# flake8-quotes
"Q",
# flake8-return
"RET",
# flake8-raise
"RSE",
# Ruff-specific rules
"RUF",
# flake8-bandit
"S",
# flake8-simplify
"SIM",
# flake8-slots
"SLOT",
# flake8-debugger
"T10",
# flake8-type-checking
"TC",
# pyupgrade
"UP",
# pycodestyle warnings
"W",
# flake8-2020
"YTT",
]
ignore = [
# Missing docstring in public module
"D100",
# Missing docstring in public class
"D101",
# Missing docstring in public function
"D103",
# Missing docstring in public package
"D104",
# Missing docstring in magic method
"D105",
# Missing docstring in __init__
"D107",
# One-line docstring should fit on one line with quotes
"D200",
# No blank lines allowed after function docstring
"D202",
# 1 blank line required between summary line and description
"D205",
# Multi-line docstring closing quotes should be on a separate line
"D209",
# First line should end with a period
"D400",
# First line should be in imperative mood; try rephrasing
"D401",
# First line should not be the function's "signature"
"D402",
# Too many return statements
"PLR0911",
# Too many branches
"PLR0912",
# Too many arguments in function definition
"PLR0913",
# Too many statements
"PLR0915",
# Magic value used in comparison
"PLR2004",
# Mutable class attributes should be annotated with `typing.ClassVar`
"RUF012",
# Use of `assert` detected
"S101",
]

[tool.ruff.lint.per-file-ignores]
# D102: Missing docstring in public method
"tests/**" = ["D102"]

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

[tool.setuptools]
packages = ["scrapy_deltafetch"]
1 change: 0 additions & 1 deletion requirements.txt

This file was deleted.

2 changes: 1 addition & 1 deletion scrapy_deltafetch/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .middleware import DeltaFetch


__all__ = ["DeltaFetch"]
__version__ = "2.0.1"
Loading