Skip to content

Commit a1ac23a

Browse files
committed
Merge branch 'main' into mernmic-main
2 parents e54eace + 8321dc1 commit a1ac23a

19 files changed

+227
-295
lines changed

.github/workflows/ci.yml

Lines changed: 42 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44
push:
55
branches:
66
- main
7-
- v0.23-branch
87
tags:
98
- '**'
109
pull_request: {}
@@ -14,12 +13,12 @@ jobs:
1413
runs-on: ubuntu-latest
1514

1615
steps:
17-
- uses: actions/checkout@v2
16+
- uses: actions/checkout@v4
1817

1918
- name: set up python
20-
uses: actions/setup-python@v4
19+
uses: actions/setup-python@v5
2120
with:
22-
python-version: '3.10'
21+
python-version: '3.11'
2322

2423
- run: pip install -r requirements/linting.txt -r requirements/pyproject.txt pre-commit
2524

@@ -29,20 +28,20 @@ jobs:
2928
runs-on: ubuntu-latest
3029

3130
steps:
32-
- uses: actions/checkout@v2
31+
- uses: actions/checkout@v4
3332

3433
- name: set up python
35-
uses: actions/setup-python@v4
34+
uses: actions/setup-python@v5
3635
with:
37-
python-version: '3.10'
36+
python-version: '3.11'
3837

3938
- run: pip install -r requirements/docs.txt -r requirements/pyproject.txt
4039
- run: pip install .
4140

4241
- run: make docs
4342

4443
- name: Store docs site
45-
uses: actions/upload-artifact@v3
44+
uses: actions/upload-artifact@v4
4645
with:
4746
name: docs
4847
path: docs/_build/
@@ -53,21 +52,21 @@ jobs:
5352
fail-fast: false
5453
matrix:
5554
os: [ubuntu]
56-
python: ['3.7', '3.8', '3.9', '3.10', '3.11']
55+
python: ['3.8', '3.9', '3.10', '3.11', '3.12']
5756
redis: ['5']
5857
include:
59-
- python: '3.10'
58+
- python: '3.11'
6059
redis: '6'
6160
os: 'ubuntu'
62-
- python: '3.10'
61+
- python: '3.11'
6362
redis: '7'
6463
os: 'ubuntu'
6564

6665
env:
6766
PYTHON: ${{ matrix.python }}
6867
OS: ${{ matrix.os }}
6968

70-
runs-on: ${{ format('{0}-latest', matrix.os) }}
69+
runs-on: ${{ matrix.os }}-latest
7170

7271
services:
7372
redis:
@@ -77,10 +76,10 @@ jobs:
7776
options: --entrypoint redis-server
7877

7978
steps:
80-
- uses: actions/checkout@v2
79+
- uses: actions/checkout@v4
8180

8281
- name: set up python
83-
uses: actions/setup-python@v4
82+
uses: actions/setup-python@v5
8483
with:
8584
python-version: ${{ matrix.python }}
8685

@@ -90,50 +89,61 @@ jobs:
9089

9190
- run: coverage xml
9291

93-
- uses: codecov/codecov-action@v2
92+
- uses: codecov/codecov-action@v4
9493
with:
9594
file: ./coverage.xml
9695
env_vars: PYTHON,OS
9796

98-
deploy:
99-
name: Deploy
97+
check:
98+
if: always()
10099
needs: [lint, docs, test]
100+
runs-on: ubuntu-latest
101+
102+
steps:
103+
- name: Decide whether the needed jobs succeeded or failed
104+
uses: re-actors/alls-green@release/v1
105+
id: all-green
106+
with:
107+
jobs: ${{ toJSON(needs) }}
108+
109+
release:
110+
name: Release
111+
needs: [check]
101112
if: "success() && startsWith(github.ref, 'refs/tags/')"
102113
runs-on: ubuntu-latest
114+
environment: release
115+
116+
permissions:
117+
id-token: write
103118

104119
steps:
105-
- uses: actions/checkout@v2
120+
- uses: actions/checkout@v4
106121

107122
- name: get docs
108-
uses: actions/download-artifact@v3
123+
uses: actions/download-artifact@v4
109124
with:
110125
name: docs
111126
path: docs/_build/
112127

113128
- name: set up python
114-
uses: actions/setup-python@v4
129+
uses: actions/setup-python@v5
115130
with:
116-
python-version: '3.10'
131+
python-version: '3.11'
117132

118133
- name: install
119-
run: pip install -U twine build packaging
134+
run: pip install -U build
120135

121136
- name: check version
122137
id: check-version
123-
run: python <(curl -Ls https://gist.githubusercontent.com/samuelcolvin/4e1ad439c5489e8d6478cdee3eb952ef/raw/check_version.py)
124-
env:
125-
VERSION_PATH: 'arq/version.py'
138+
uses: samuelcolvin/check-python[email protected]
139+
with:
140+
version_file_path: 'arq/version.py'
126141

127142
- name: build
128143
run: python -m build
129144

130-
- run: twine check dist/*
131-
132-
- name: upload to pypi
133-
run: twine upload dist/*
134-
env:
135-
TWINE_USERNAME: __token__
136-
TWINE_PASSWORD: ${{ secrets.pypi_token }}
145+
- name: Upload package to PyPI
146+
uses: pypa/gh-action-pypi-publish@release/v1
137147

138148
- name: publish docs
139149
if: '!fromJSON(steps.check-version.outputs.IS_PRERELEASE)'

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ repos:
1111

1212
- repo: local
1313
hooks:
14-
- id: lint
15-
name: Lint
16-
entry: make lint
14+
- id: format
15+
name: Format
16+
entry: make format
1717
types: [python]
1818
language: system
1919
pass_filenames: false

Makefile

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,36 @@
11
.DEFAULT_GOAL := all
2-
isort = isort arq tests
3-
black = black arq tests
2+
sources = arq tests
43

54
.PHONY: install
65
install:
7-
pip install -U pip pre-commit
6+
pip install -U pip pre-commit pip-tools
87
pip install -r requirements/all.txt
98
pip install -e .[watch]
109
pre-commit install
1110

11+
.PHONY: refresh-lockfiles
12+
refresh-lockfiles:
13+
find requirements/ -name '*.txt' ! -name 'all.txt' -type f -delete
14+
make update-lockfiles
15+
16+
.PHONY: update-lockfiles
17+
update-lockfiles:
18+
@echo "Updating requirements/*.txt files using pip-compile"
19+
pip-compile -q --strip-extras -o requirements/linting.txt requirements/linting.in
20+
pip-compile -q --strip-extras -o requirements/testing.txt requirements/testing.in
21+
pip-compile -q --strip-extras -o requirements/docs.txt requirements/docs.in
22+
pip-compile -q --strip-extras -o requirements/pyproject.txt pyproject.toml --all-extras
23+
pip install --dry-run -r requirements/all.txt
24+
1225
.PHONY: format
1326
format:
14-
$(isort)
15-
$(black)
27+
ruff check --fix $(sources)
28+
ruff format $(sources)
1629

1730
.PHONY: lint
1831
lint:
19-
flake8 --max-complexity 10 --max-line-length 120 --ignore E203,W503 arq/ tests/
20-
$(isort) --check-only --df
21-
$(black) --check
32+
ruff check $(sources)
33+
ruff format --check $(sources)
2234

2335
.PHONY: test
2436
test:

arq/connections.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from dataclasses import dataclass
55
from datetime import datetime, timedelta
66
from operator import attrgetter
7-
from typing import TYPE_CHECKING, Any, Callable, List, Optional, Tuple, Union
7+
from typing import TYPE_CHECKING, Any, Callable, List, Optional, Tuple, Union, cast
88
from urllib.parse import parse_qs, urlparse
99
from uuid import uuid4
1010

@@ -168,8 +168,8 @@ async def enqueue_job(
168168

169169
job = serialize_job(function, args, kwargs, _job_try, enqueue_time_ms, serializer=self.job_serializer)
170170
pipe.multi()
171-
pipe.psetex(job_key, expires_ms, job) # type: ignore[no-untyped-call]
172-
pipe.zadd(_queue_name, {job_id: score}) # type: ignore[unused-coroutine]
171+
pipe.psetex(job_key, expires_ms, job)
172+
pipe.zadd(_queue_name, {job_id: score})
173173
try:
174174
await pipe.execute()
175175
except WatchError:
@@ -215,7 +215,7 @@ async def queued_jobs(self, *, queue_name: Optional[str] = None) -> List[JobDef]
215215

216216

217217
async def create_pool(
218-
settings_: RedisSettings = None,
218+
settings_: Optional[RedisSettings] = None,
219219
*,
220220
retry: int = 0,
221221
job_serializer: Optional[Serializer] = None,
@@ -242,7 +242,8 @@ def pool_factory(*args: Any, **kwargs: Any) -> ArqRedis:
242242
ssl=settings.ssl,
243243
**kwargs,
244244
)
245-
return client.master_for(settings.sentinel_master, redis_class=ArqRedis)
245+
redis = client.master_for(settings.sentinel_master, redis_class=ArqRedis)
246+
return cast(ArqRedis, redis)
246247

247248
else:
248249
pool_factory = functools.partial(
@@ -296,10 +297,10 @@ def pool_factory(*args: Any, **kwargs: Any) -> ArqRedis:
296297

297298
async def log_redis_info(redis: 'Redis[bytes]', log_func: Callable[[str], Any]) -> None:
298299
async with redis.pipeline(transaction=False) as pipe:
299-
pipe.info(section='Server') # type: ignore[unused-coroutine]
300-
pipe.info(section='Memory') # type: ignore[unused-coroutine]
301-
pipe.info(section='Clients') # type: ignore[unused-coroutine]
302-
pipe.dbsize() # type: ignore[unused-coroutine]
300+
pipe.info(section='Server')
301+
pipe.info(section='Memory')
302+
pipe.info(section='Clients')
303+
pipe.dbsize()
303304
info_server, info_memory, info_clients, key_count = await pipe.execute()
304305

305306
redis_version = info_server.get('redis_version', '?')

arq/jobs.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def __init__(
8383
self._deserializer = _deserializer
8484

8585
async def result(
86-
self, timeout: Optional[float] = None, *, poll_delay: float = 0.5, pole_delay: float = None
86+
self, timeout: Optional[float] = None, *, poll_delay: float = 0.5, pole_delay: Optional[float] = None
8787
) -> Any:
8888
"""
8989
Get the result of the job or, if the job raised an exception, reraise it.
@@ -103,8 +103,8 @@ async def result(
103103

104104
async for delay in poll(poll_delay):
105105
async with self._redis.pipeline(transaction=True) as tr:
106-
tr.get(result_key_prefix + self.job_id) # type: ignore[unused-coroutine]
107-
tr.zscore(self._queue_name, self.job_id) # type: ignore[unused-coroutine]
106+
tr.get(result_key_prefix + self.job_id)
107+
tr.zscore(self._queue_name, self.job_id)
108108
v, s = await tr.execute()
109109

110110
if v:
@@ -154,9 +154,9 @@ async def status(self) -> JobStatus:
154154
Status of the job.
155155
"""
156156
async with self._redis.pipeline(transaction=True) as tr:
157-
tr.exists(result_key_prefix + self.job_id) # type: ignore[unused-coroutine]
158-
tr.exists(in_progress_key_prefix + self.job_id) # type: ignore[unused-coroutine]
159-
tr.zscore(self._queue_name, self.job_id) # type: ignore[unused-coroutine]
157+
tr.exists(result_key_prefix + self.job_id)
158+
tr.exists(in_progress_key_prefix + self.job_id)
159+
tr.zscore(self._queue_name, self.job_id)
160160
is_complete, is_in_progress, score = await tr.execute()
161161

162162
if is_complete:
@@ -180,8 +180,8 @@ async def abort(self, *, timeout: Optional[float] = None, poll_delay: float = 0.
180180
job_info = await self.info()
181181
if job_info and job_info.score and job_info.score > timestamp_ms():
182182
async with self._redis.pipeline(transaction=True) as tr:
183-
tr.zrem(self._queue_name, self.job_id) # type: ignore[unused-coroutine]
184-
tr.zadd(self._queue_name, {self.job_id: 1}) # type: ignore[unused-coroutine]
183+
tr.zrem(self._queue_name, self.job_id)
184+
tr.zadd(self._queue_name, {self.job_id: 1})
185185
await tr.execute()
186186

187187
await self._redis.zadd(abort_jobs_ss, {self.job_id: timestamp_ms()})

arq/typing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020

2121
if TYPE_CHECKING:
22-
from .cron import CronJob # noqa F401
23-
from .worker import Function # noqa F401
22+
from .cron import CronJob
23+
from .worker import Function
2424

2525
OptionType = Union[None, Set[int], int]
2626
WEEKDAYS = 'mon', 'tues', 'wed', 'thurs', 'fri', 'sat', 'sun'

0 commit comments

Comments
 (0)