Skip to content

Commit f8cb494

Browse files
authored
Drop python <3.10, general maintenance updates (#257)
- Drop python 3.8, 3.9, as per https://numpy.org/neps/nep-0029-deprecation_policy.html - Update and run pre-commits. - Replace pkg_resource with importlib.metadata, fixes #256. - Ignore autogenerated models file in mypy. - Use ruff-format instead of black.
1 parent b1bf88f commit f8cb494

27 files changed

+286
-295
lines changed

.github/workflows/build_and_test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
runs-on: ubuntu-latest
3030
strategy:
3131
matrix:
32-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
32+
python-version: ["3.10", "3.11", "3.12"]
3333

3434
steps:
3535
- uses: actions/checkout@v3

.github/workflows/linting.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ jobs:
1313
uses: actions/checkout@v3
1414

1515
- name: Ruff Check
16-
uses: jpetrucciani/ruff-check@33f3725e751a187bb666b7d7a7094d38a2df12db # 0.0.239
16+
uses: jpetrucciani/ruff-check@96f59856544cbfba111afdf2f6985e21756b8e7e # 0.6.2

.pre-commit-config.yaml

+11-14
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
ci:
2+
autoupdate_schedule: quarterly
3+
skip: [poetry-lock]
4+
15
repos:
26
# Syntax validation and some basic sanity checks
37
- repo: https://github.com/pre-commit/pre-commit-hooks
4-
rev: v4.4.0
8+
rev: v4.6.0
59
hooks:
610
- id: check-merge-conflict
711
- id: check-ast
@@ -11,34 +15,27 @@ repos:
1115
args: ['--maxkb=200']
1216
- id: check-yaml
1317

14-
- repo: https://github.com/charliermarsh/ruff-pre-commit
15-
rev: v0.0.286
18+
- repo: https://github.com/astral-sh/ruff-pre-commit
19+
rev: v0.6.2
1620
hooks:
1721
- id: ruff
1822
args: [--fix, --show-fixes, --exit-non-zero-on-fix]
19-
20-
# Automatic source code formatting
21-
- repo: https://github.com/psf/black
22-
rev: 23.7.0
23-
hooks:
24-
- id: black
25-
args: [--safe, --quiet]
23+
- id: ruff-format
2624

2725
# Type checking
2826
- repo: https://github.com/pre-commit/mirrors-mypy
29-
rev: v1.5.1
27+
rev: v1.11.2
3028
hooks:
3129
- id: mypy
3230
files: 'src/.*\.py$'
3331
additional_dependencies:
3432
- types-requests
35-
- types-pkg_resources
3633
- types-pyyaml
3734

3835
- repo: https://github.com/python-poetry/poetry
3936
rev: 1.8.0
40-
additional_dependencies: ["poetry-plugin-export"]
4137
hooks:
4238
- id: poetry-lock
4339
- id: poetry-export
44-
args: [-o, requirements_dev.txt, --with=dev, --without-hashes]
40+
additional_dependencies: [poetry-plugin-export]
41+
args: [-o, requirements_dev.txt, --with=dev, --without-hashes]

poetry.lock

+195-216
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+10-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ classifiers = [
1414
]
1515

1616
[tool.poetry.dependencies]
17-
python = "^3.8"
17+
python = "^3.10"
1818
pyyaml = "^6.0"
1919
graypy = "^2.0"
2020
marshmallow = "^3.19"
@@ -89,29 +89,32 @@ iris = "zocalo.configuration.plugin_slurm:Slurm"
8989
smtp = "zocalo.configuration.plugin_smtp:SMTP"
9090
storage = "zocalo.configuration.plugin_storage:Storage"
9191

92-
[tool.isort]
93-
profile = "black"
94-
9592
[tool.pytest.ini_options]
9693
required_plugins = "pytest-mock requests-mock"
9794
testpaths = ["tests"]
9895

99-
[tool.ruff]
100-
line-length = 88
96+
[tool.ruff.lint]
10197
ignore = ["E501", "E741"]
10298
select = ["C4", "E", "F", "W", "I"]
10399
unfixable = ["F841"]
104100

105-
[tool.ruff.isort]
101+
[tool.ruff.lint.isort]
106102
required-imports = ["from __future__ import annotations"]
107103

104+
[tool.ruff.lint.per-file-ignores]
105+
"src/zocalo/util/slurm/models.py" = ["W"]
106+
108107
[tool.mypy]
109108
mypy_path = "src"
110109

111110
[[tool.mypy.overrides]]
112111
module = ["graypy", "graypy.handler"]
113112
ignore_missing_imports = true
114113

114+
[[tool.mypy.overrides]]
115+
module = ["zocalo.util.slurm.models"]
116+
ignore_errors = true
117+
115118
[tool.bumpversion]
116119
current_version = "1.0.0"
117120
commit = true

requirements_dev.txt

+30-30
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
annotated-types==0.7.0 ; python_version >= "3.8" and python_version < "4.0"
2-
bidict==0.23.1 ; python_version >= "3.8" and python_version < "4.0"
3-
certifi==2024.7.4 ; python_version >= "3.8" and python_version < "4.0"
4-
charset-normalizer==3.3.2 ; python_version >= "3.8" and python_version < "4.0"
5-
colorama==0.4.6 ; python_version >= "3.8" and python_version < "4.0" and sys_platform == "win32"
6-
coverage[toml]==7.6.0 ; python_version >= "3.8" and python_version < "4.0"
7-
docopt==0.6.2 ; python_version >= "3.8" and python_version < "4.0"
8-
exceptiongroup==1.2.2 ; python_version >= "3.8" and python_version < "3.11"
9-
graypy==2.1.0 ; python_version >= "3.8" and python_version < "4.0"
10-
idna==3.7 ; python_version >= "3.8" and python_version < "4.0"
11-
iniconfig==2.0.0 ; python_version >= "3.8" and python_version < "4.0"
12-
marshmallow==3.21.3 ; python_version >= "3.8" and python_version < "4.0"
13-
packaging==24.1 ; python_version >= "3.8" and python_version < "4.0"
14-
pika==1.3.2 ; python_version >= "3.8" and python_version < "4.0"
15-
pluggy==1.5.0 ; python_version >= "3.8" and python_version < "4.0"
16-
pydantic-core==2.20.1 ; python_version >= "3.8" and python_version < "4.0"
17-
pydantic==2.8.2 ; python_version >= "3.8" and python_version < "4.0"
18-
pytest-cov==5.0.0 ; python_version >= "3.8" and python_version < "4.0"
19-
pytest-mock==3.14.0 ; python_version >= "3.8" and python_version < "4.0"
20-
pytest==8.2.2 ; python_version >= "3.8" and python_version < "4.0"
21-
pyyaml==6.0.1 ; python_version >= "3.8" and python_version < "4.0"
22-
requests-mock==1.12.1 ; python_version >= "3.8" and python_version < "4.0"
23-
requests==2.32.3 ; python_version >= "3.8" and python_version < "4.0"
24-
setuptools==71.0.3 ; python_version >= "3.8" and python_version < "4.0"
25-
stomp-py==8.1.2 ; python_version >= "3.8" and python_version < "4.0"
26-
tomli==2.0.1 ; python_version >= "3.8" and python_full_version <= "3.11.0a6"
27-
typing-extensions==4.12.2 ; python_version >= "3.8" and python_version < "4.0"
28-
urllib3==2.2.2 ; python_version >= "3.8" and python_version < "4.0"
29-
websocket-client==1.8.0 ; python_version >= "3.8" and python_version < "4.0"
30-
workflows==2.27 ; python_version >= "3.8" and python_version < "4.0"
1+
annotated-types==0.7.0 ; python_version >= "3.10" and python_version < "4.0"
2+
bidict==0.23.1 ; python_version >= "3.10" and python_version < "4.0"
3+
certifi==2024.7.4 ; python_version >= "3.10" and python_version < "4.0"
4+
charset-normalizer==3.3.2 ; python_version >= "3.10" and python_version < "4.0"
5+
colorama==0.4.6 ; python_version >= "3.10" and python_version < "4.0" and sys_platform == "win32"
6+
coverage[toml]==7.6.1 ; python_version >= "3.10" and python_version < "4.0"
7+
docopt==0.6.2 ; python_version >= "3.10" and python_version < "4.0"
8+
exceptiongroup==1.2.2 ; python_version >= "3.10" and python_version < "3.11"
9+
graypy==2.1.0 ; python_version >= "3.10" and python_version < "4.0"
10+
idna==3.8 ; python_version >= "3.10" and python_version < "4.0"
11+
iniconfig==2.0.0 ; python_version >= "3.10" and python_version < "4.0"
12+
marshmallow==3.22.0 ; python_version >= "3.10" and python_version < "4.0"
13+
packaging==24.1 ; python_version >= "3.10" and python_version < "4.0"
14+
pika==1.3.2 ; python_version >= "3.10" and python_version < "4.0"
15+
pluggy==1.5.0 ; python_version >= "3.10" and python_version < "4.0"
16+
pydantic-core==2.20.1 ; python_version >= "3.10" and python_version < "4.0"
17+
pydantic==2.8.2 ; python_version >= "3.10" and python_version < "4.0"
18+
pytest-cov==5.0.0 ; python_version >= "3.10" and python_version < "4.0"
19+
pytest-mock==3.14.0 ; python_version >= "3.10" and python_version < "4.0"
20+
pytest==8.3.2 ; python_version >= "3.10" and python_version < "4.0"
21+
pyyaml==6.0.2 ; python_version >= "3.10" and python_version < "4.0"
22+
requests-mock==1.12.1 ; python_version >= "3.10" and python_version < "4.0"
23+
requests==2.32.3 ; python_version >= "3.10" and python_version < "4.0"
24+
setuptools==74.0.0 ; python_version >= "3.10" and python_version < "4.0"
25+
stomp-py==8.1.2 ; python_version >= "3.10" and python_version < "4.0"
26+
tomli==2.0.1 ; python_version >= "3.10" and python_full_version <= "3.11.0a6"
27+
typing-extensions==4.12.2 ; python_version >= "3.10" and python_version < "4.0"
28+
urllib3==2.2.2 ; python_version >= "3.10" and python_version < "4.0"
29+
websocket-client==1.8.0 ; python_version >= "3.10" and python_version < "4.0"
30+
workflows==2.27 ; python_version >= "3.10" and python_version < "4.0"

src/zocalo/cli/wrap.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
import logging
1212
import signal
1313
import sys
14+
from importlib.metadata import entry_points
1415

15-
import pkg_resources
1616
import workflows.recipe.wrapper
1717
import workflows.services.common_service
1818
import workflows.transport
@@ -40,9 +40,7 @@ def run():
4040
zc = zocalo.configuration.from_file()
4141
zc.activate()
4242

43-
known_wrappers = {
44-
e.name: e.load for e in pkg_resources.iter_entry_points("zocalo.wrappers")
45-
}
43+
known_wrappers = {e.name: e.load for e in entry_points(group="zocalo.wrappers")}
4644

4745
# Set up parser
4846
parser = argparse.ArgumentParser(usage="zocalo.wrap [options]")

src/zocalo/configuration/__init__.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
import os
1010
import pathlib
1111
import typing
12+
from importlib.metadata import entry_points
1213

1314
import marshmallow as mm
14-
import pkg_resources
1515
import yaml
1616

1717
import zocalo.configuration.argparse
@@ -56,7 +56,7 @@ def _check_valid_plugin_name(name: str) -> bool:
5656

5757
_configuration_plugins = {
5858
e.name: e
59-
for e in pkg_resources.iter_entry_points("zocalo.configuration.plugins")
59+
for e in entry_points(group="zocalo.configuration.plugins")
6060
if _check_valid_plugin_name(e.name)
6161
}
6262

@@ -208,8 +208,7 @@ def add_command_line_options(self, parser):
208208
# attributes is allowed. We do this by setting a return type on __getattr__,
209209
# but only when in a type checking run, as to not affect the runtime class
210210
# behaviour.
211-
def __getattr__(self, name: str) -> typing.Any:
212-
...
211+
def __getattr__(self, name: str) -> typing.Any: ...
213212

214213
def __str__(self):
215214
environments = len(self._environments)

src/zocalo/service/dispatcher.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import time
99
import timeit
1010
import uuid
11+
from importlib.metadata import entry_points
1112

12-
import pkg_resources
1313
import workflows.recipe
1414
from workflows.services.common_service import CommonService
1515

@@ -110,9 +110,7 @@ def initializing(self):
110110
self.message_filters = {
111111
**{
112112
f.name: f.load()
113-
for f in pkg_resources.iter_entry_points(
114-
"zocalo.services.dispatcher.filters"
115-
)
113+
for f in entry_points(group="zocalo.services.dispatcher.filters")
116114
},
117115
"load_custom_recipe": self.filter_load_custom_recipe,
118116
"load_recipes_from_files": self.filter_load_recipes_from_files,
@@ -121,8 +119,8 @@ def initializing(self):
121119

122120
self.ready_for_processing = {
123121
f.name: f.load()
124-
for f in pkg_resources.iter_entry_points(
125-
"zocalo.services.dispatcher.ready_for_processing"
122+
for f in entry_points(
123+
group="zocalo.services.dispatcher.ready_for_processing"
126124
)
127125
}
128126

src/zocalo/service/schlockmeister.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,14 @@ def update_subscriptions(self):
186186
)
187187
if real_subscriber_count:
188188
self.log.debug("subscribing to %s", destination)
189-
self.known_queues[destination][
190-
"subscription"
191-
] = self._transport.subscribe(
192-
destination,
193-
self.quarantine,
194-
acknowledgement=True,
195-
selector="JMSXDeliveryCount>5",
196-
disable_mangling=True,
189+
self.known_queues[destination]["subscription"] = (
190+
self._transport.subscribe(
191+
destination,
192+
self.quarantine,
193+
acknowledgement=True,
194+
selector="JMSXDeliveryCount>5",
195+
disable_mangling=True,
196+
)
197197
)
198198

199199
def garbage_collect(self):

tests/cli/test_dlq_purge.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
from unittest import mock
66

77
import workflows.transport
8-
import zocalo.cli.dlq_purge as dlq_purge
98
from workflows.transport.common_transport import CommonTransport
109

10+
import zocalo.cli.dlq_purge as dlq_purge
11+
1112

1213
def gen_header_activemq(i):
1314
return {

tests/cli/test_dlq_reinject.py

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import workflows.transport
1010
from workflows.transport.common_transport import CommonTransport
11+
1112
from zocalo.cli.dlq_reinject import run
1213

1314

tests/cli/test_pickup.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88

99
import pytest
1010
import workflows.transport
11-
import zocalo.configuration
1211
from workflows.transport.common_transport import CommonTransport
12+
13+
import zocalo.configuration
1314
from zocalo.cli import pickup
1415

1516

tests/cli/test_queue_drain.py

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import workflows.transport
66
from workflows.transport.common_transport import CommonTransport
7+
78
from zocalo.cli.queue_drain import run
89

910

tests/cli/test_shutdown.py

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import workflows.transport
77
from workflows.transport.common_transport import CommonTransport
88
from workflows.util import generate_unique_host_id
9+
910
from zocalo.cli.shutdown import run
1011

1112

tests/configuration/test_configuration.py

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from unittest import mock
88

99
import pytest
10+
1011
import zocalo.configuration
1112

1213
sample_configuration = """

tests/configuration/test_plugin_graylog.py

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from unittest import mock
44

55
import pytest
6+
67
import zocalo.configuration
78

89
sample_configuration = """

tests/configuration/test_plugin_jmx.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import pytest
4+
45
import zocalo.configuration
56

67
sample_configuration = """

tests/configuration/test_plugin_logging.py

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from unittest import mock
55

66
import pytest
7+
78
import zocalo.configuration
89
import zocalo.configuration.plugin_logging
910

tests/configuration/test_plugin_slurm.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import pytest
4+
45
import zocalo.configuration
56

67
sample_configuration = """

tests/configuration/test_plugin_smtp.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import pytest
4+
45
import zocalo.configuration
56

67
sample_configuration = """

tests/service/test_dispatcher.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
from unittest import mock
55

66
import pytest
7-
import zocalo.configuration
87
from workflows.recipe import Recipe
98
from workflows.transport.offline_transport import OfflineTransport
9+
10+
import zocalo.configuration
1011
from zocalo.service.dispatcher import Dispatcher
1112

1213

tests/service/test_jsonlines.py

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from workflows.recipe.wrapper import RecipeWrapper
66
from workflows.transport.offline_transport import OfflineTransport
7+
78
from zocalo.service.jsonlines import JSONLines
89

910

0 commit comments

Comments
 (0)