Skip to content

Commit f5ca233

Browse files
authored
General backend refresh (#474)
* Update pre-commit and pyproject.toml * Compile requirements files on commit * Remove CI checks done by pre-commit * More migration off python 3.8 * Rename references master -> main * Run general pyupgrade fixes
1 parent c99a613 commit f5ca233

14 files changed

Lines changed: 150 additions & 192 deletions

.azure-pipelines/azure-pipelines.yml

Lines changed: 11 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,6 @@ stages:
77
pool:
88
vmImage: ubuntu-20.04
99
steps:
10-
# Run syntax validation using oldest and latest Python
11-
- task: UsePythonVersion@0
12-
displayName: Set up python
13-
inputs:
14-
versionSpec: 3.8
15-
16-
- bash: python .azure-pipelines/syntax-validation.py
17-
displayName: Syntax validation (3.7)
18-
19-
- task: UsePythonVersion@0
20-
displayName: Set up python
21-
inputs:
22-
versionSpec: 3.11
23-
24-
- bash: python .azure-pipelines/syntax-validation.py
25-
displayName: Syntax validation (3.10)
26-
27-
- bash: |
28-
set -eux
29-
pip install --disable-pip-version-check ruff
30-
python .azure-pipelines/ruff-validation.py
31-
displayName: Ruff validation
32-
33-
- bash: |
34-
set -eux
35-
# install versions matching the ones in the corresponding pre-commit hook
36-
pip install --disable-pip-version-check mypy==1.9.0 types-PyYAML==6.0.12 types-requests==2.31.0
37-
mypy --no-strict-optional dials_data/
38-
displayName: Type checking
39-
4010
# Set up constants for further build steps
4111
- bash: |
4212
echo "##vso[task.setvariable variable=BUILD_REPOSITORY_NAME;isOutput=true]${BUILD_REPOSITORY_NAME}"
@@ -157,44 +127,47 @@ stages:
157127
vmImage: ubuntu-20.04
158128
strategy:
159129
matrix:
160-
python38:
161-
PYTHON_VERSION: 3.8
162130
python39:
163131
PYTHON_VERSION: 3.9
164132
python310:
165133
PYTHON_VERSION: 3.10
166134
python311:
167135
PYTHON_VERSION: 3.11
136+
python312:
137+
PYTHON_VERSION: 3.12
138+
168139
steps:
169140
- template: ci.yml
170141
- job: macOS
171142
pool:
172143
vmImage: macOS-latest
173144
strategy:
174145
matrix:
175-
python38:
176-
PYTHON_VERSION: 3.8
177146
python39:
178147
PYTHON_VERSION: 3.9
179148
python310:
180149
PYTHON_VERSION: 3.10
181150
python311:
182151
PYTHON_VERSION: 3.11
152+
python312:
153+
PYTHON_VERSION: 3.12
154+
183155
steps:
184156
- template: ci.yml
185157
- job: windows
186158
pool:
187159
vmImage: windows-latest
188160
strategy:
189161
matrix:
190-
python38:
191-
PYTHON_VERSION: 3.8
192162
python39:
193163
PYTHON_VERSION: 3.9
194164
python310:
195165
PYTHON_VERSION: 3.10
196166
python311:
197167
PYTHON_VERSION: 3.11
168+
python312:
169+
PYTHON_VERSION: 3.12
170+
198171
steps:
199172
- template: ci-windows.yml
200173

@@ -205,7 +178,7 @@ stages:
205178
- tests
206179
condition: and(succeeded(),
207180
eq(dependencies.static.outputs['checks.constants.BUILD_REPOSITORY_NAME'], 'dials/data'),
208-
eq(dependencies.static.outputs['checks.constants.BUILD_SOURCEBRANCH'], 'refs/heads/master'))
181+
eq(dependencies.static.outputs['checks.constants.BUILD_SOURCEBRANCH'], 'refs/heads/main'))
209182
jobs:
210183
- job: pypi
211184
displayName: Publish pypi release
@@ -247,7 +220,7 @@ stages:
247220
- build
248221
- tests
249222
condition: and(succeeded(),
250-
eq(dependencies.static.outputs['checks.constants.BUILD_SOURCEBRANCH'], 'refs/heads/master'),
223+
eq(dependencies.static.outputs['checks.constants.BUILD_SOURCEBRANCH'], 'refs/heads/main'),
251224
eq(dependencies.static.outputs['checks.constants.BUILD_REPOSITORY_NAME'], 'dials/data'))
252225
# only run this job in the main branch of the main repository
253226
jobs:

.azure-pipelines/create-hashinfo-pull-requests

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ echo
1717

1818
echo "##[section]Open pull requests:"
1919
declare -A UPDATEBRANCHES
20-
for BRANCH in $(hub pr list -b master -f '%H%n'); do
20+
for BRANCH in $(hub pr list -b main -f '%H%n'); do
2121
echo ${BRANCH}
2222
UPDATEBRANCHES[${BRANCH}]=1
2323
done

.azure-pipelines/ruff-validation.py

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

.azure-pipelines/syntax-validation.py

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

.codecov.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ coverage:
1212
comment:
1313
layout: "diff, flags"
1414
branches:
15-
- master
15+
- main
1616
after_n_builds: 3

.github/workflows/codeql.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: "CodeQL"
22

33
on:
44
push:
5-
branches: [ "master" ]
5+
branches: ["main"]
66
pull_request:
7-
branches: [ "master" ]
7+
branches: ["main"]
88
schedule:
99
- cron: "22 2 * * 3"
1010

@@ -20,7 +20,7 @@ jobs:
2020
strategy:
2121
fail-fast: false
2222
matrix:
23-
language: [ javascript, python ]
23+
language: [javascript, python]
2424

2525
steps:
2626
- name: Checkout

.pre-commit-config.yaml

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
ci:
2+
autoupdate_schedule: quarterly
3+
skip: [pip-compile]
4+
15
repos:
26
# Syntax validation and some basic sanity checks
37
- repo: https://github.com/pre-commit/pre-commit-hooks
4-
rev: v4.5.0
8+
rev: v5.0.0
59
hooks:
610
- id: check-merge-conflict
711
- id: check-ast
@@ -12,8 +16,8 @@ repos:
1216
- id: check-yaml
1317

1418
# Linting, sorting and formatting
15-
- repo: https://github.com/charliermarsh/ruff-pre-commit
16-
rev: v0.3.3
19+
- repo: https://github.com/astral-sh/ruff-pre-commit
20+
rev: v0.7.2
1721
hooks:
1822
- id: ruff
1923
args: [--fix, --exit-non-zero-on-fix]
@@ -23,8 +27,21 @@ repos:
2327
# Remember to change versions in .azure-pipelines/azure-pipelines.yml to match
2428
# the versions here.
2529
- repo: https://github.com/pre-commit/mirrors-mypy
26-
rev: v1.9.0
30+
rev: v1.13.0
2731
hooks:
2832
- id: mypy
2933
files: 'dials_data/.*\.py$'
3034
additional_dependencies: ['types-PyYAML==6.0.12', 'types-requests==2.31.0']
35+
36+
- repo: https://github.com/astral-sh/uv-pre-commit
37+
rev: 0.4.30
38+
hooks:
39+
- id: pip-compile
40+
args: [pyproject.toml, -q, -o, requirements.txt]
41+
files: ^(pyproject.toml|requirements(_dev|_doc)?.txt)$
42+
- id: pip-compile
43+
args: [pyproject.toml, -q, --extra, test, -o, requirements_dev.txt]
44+
files: ^(pyproject.toml|requirements(_dev|_doc)?.txt)$
45+
- id: pip-compile
46+
args: [pyproject.toml, -q, --extra, doc, -o, requirements_doc.txt]
47+
files: ^(pyproject.toml|requirements(_dev|_doc)?.txt)$

dials_data/cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def main():
119119
version = dials_data.__version__ + "-dev"
120120
parser = argparse.ArgumentParser(
121121
usage="dials.data <command> [<args>]",
122-
description="""DIALS regression data manager v{version}
122+
description=f"""DIALS regression data manager v{version}
123123
124124
The most commonly used commands are:
125125
list List available datasets
@@ -128,7 +128,7 @@ def main():
128128
Each command has its own set of parameters, and you can get more information
129129
by running dials.data <command> --help
130130
131-
""".format(version=version),
131+
""",
132132
formatter_class=argparse.RawTextHelpFormatter,
133133
)
134134
parser.add_argument("subcommand", help=argparse.SUPPRESS)

dials_data/datasets.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,7 @@ def list_known_definitions(ds_list, quiet=False) -> None:
134134
size_information = "unverified dataset"
135135
else:
136136
size_information = _human_readable(get_resident_size(shortname))
137-
print(
138-
"{shortname}: {dataset[name]} ({size_information})".format(
139-
shortname=shortname, dataset=dataset, size_information=size_information
140-
)
141-
)
137+
print(f"{shortname}: {dataset['name']} ({size_information})")
142138
print(
143139
"{indent}{author} ({license})".format(
144140
author=dataset.get("author", "unknown author"),
@@ -147,7 +143,7 @@ def list_known_definitions(ds_list, quiet=False) -> None:
147143
)
148144
)
149145
if dataset.get("url"):
150-
print("{indent}{dataset[url]}".format(indent=indent, dataset=dataset))
146+
print(f"{indent}{dataset['url']}")
151147
print(
152148
"\n{}\n".format(
153149
textwrap.fill(

dials_data/download.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import warnings
1111
import zipfile
1212
from pathlib import Path
13-
from typing import Any, Optional, Union
13+
from typing import Any
1414
from urllib.parse import urlparse
1515

1616
import py.path
@@ -104,7 +104,7 @@ def fetch_dataset(
104104
read_only: bool = False,
105105
verbose: bool = False,
106106
pre_scan: bool = True,
107-
) -> Union[bool, dict[str, Any]]:
107+
) -> bool | dict[str, Any]:
108108
"""Check for the presence or integrity of the local copy of the specified
109109
test dataset. If the dataset is not available or out of date then attempt
110110
to download/update it transparently.
@@ -280,7 +280,7 @@ class DataFetcher:
280280
"""
281281

282282
def __init__(self, read_only: bool = False, verify: bool = True):
283-
self._cache: dict[str, Optional[Path]] = {}
283+
self._cache: dict[str, Path | None] = {}
284284
self._target_dir: Path = dials_data.datasets.repository_location()
285285
self._read_only: bool = read_only and os.access(self._target_dir, os.W_OK)
286286
self._verify: bool = verify
@@ -332,7 +332,7 @@ def __call__(self, test_data: str, pathlib=None, **kwargs):
332332
return self.result_filter(result=py.path.local(self._cache[test_data]))
333333
return self.result_filter(result=self._cache[test_data])
334334

335-
def _attempt_fetch(self, test_data: str) -> Optional[Path]:
335+
def _attempt_fetch(self, test_data: str) -> Path | None:
336336
if self._read_only:
337337
hashinfo = fetch_dataset(test_data, pre_scan=True, read_only=True)
338338
else:

0 commit comments

Comments
 (0)