Skip to content

Commit 25b6c08

Browse files
authored
Merge pull request #682 from octue/switch-to-ruff-tooling
Switch to ruff developer tooling
2 parents d948b8f + e203b0b commit 25b6c08

23 files changed

+444
-601
lines changed

.devcontainer/devcontainer.json

+4-16
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,19 @@
99
// Set *default* container specific settings.json values on container create.
1010
"settings": {
1111
"austin.mode": "Wall time",
12-
"editor.defaultFormatter": "esbenp.prettier-vscode",
12+
"editor.defaultFormatter": "charliermarsh.ruff",
1313
"editor.formatOnSave": true,
1414
"jupyter.widgetScriptSources": ["jsdelivr.com", "unpkg.com"],
15+
"python.locator": "native",
1516
"prettier.prettierPath": "/usr/local/prettier",
1617
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
17-
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
18-
"python.formatting.provider": "black",
1918
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
2019
"python.languageServer": "Pylance",
2120
"python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
2221
"python.linting.enabled": true,
23-
"python.linting.flake8Path": "/usr/local/py-utils/bin/flake8",
2422
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy",
2523
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
2624
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
27-
// Line length to match black settings
28-
// Disabling specific messages:
29-
// - To find the details do: /usr/local/py-utils/bin/pylint --list-msgs
30-
// - Disable missing-module-docstring (C0114) because we don't document modules routinely, just their members
31-
// - Disable invalid-name (C0103) because pylint thinks that eg 'x', 'df', 'np' are invalid due to their lengths
32-
"python.linting.pylintArgs": [
33-
"--max-line-length=120",
34-
"--disable=missing-module-docstring,invalid-name"
35-
],
36-
"python.linting.pylintEnabled": true,
37-
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint",
3825
"python.pythonPath": "/usr/local/bin/python",
3926
"terminal.integrated.defaultProfile.linux": "zsh"
4027
},
@@ -51,7 +38,8 @@
5138
"ms-toolsai.jupyter-keymap",
5239
"ms-vsliveshare.vsliveshare",
5340
"p403n1x87.austin-vscode",
54-
"ritwickdey.liveserver"
41+
"ritwickdey.liveserver",
42+
"charliermarsh.ruff"
5543
],
5644

5745
// Use 'forwardPorts' to make a list of ports inside the container available locally.

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,6 @@ terraform/gcp-credentials.json
103103
.terraform
104104

105105
*.jsonl
106+
107+
# Avoid committing ruff cache files
108+
.ruff_cache

.pre-commit-config.yaml

+7-21
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,12 @@ repos:
1212
- id: check-yaml
1313
- id: check-added-large-files
1414

15-
- repo: https://github.com/PyCQA/isort
16-
rev: 5.10.1
15+
- repo: https://github.com/astral-sh/ruff-pre-commit
16+
rev: v0.6.2
1717
hooks:
18-
- id: isort
19-
20-
- repo: https://github.com/psf/black
21-
rev: 24.4.2
22-
hooks:
23-
- id: black
24-
args: ["--line-length", "120"]
25-
26-
- repo: https://github.com/pycqa/flake8
27-
rev: 6.0.0
28-
hooks:
29-
- id: flake8
30-
language_version: python3
31-
additional_dependencies:
32-
- "pep8-naming"
33-
args:
34-
- --ignore-names=setUp,tearDown,setUpClass,tearDownClass,asyncSetUp,asyncTearDown,setUpTestData,failureException,longMessage,maxDiff,startTestRun,stopTestRun
18+
- id: ruff
19+
args: [--fix, --exit-non-zero-on-fix]
20+
- id: ruff-format
3521

3622
- repo: https://github.com/pre-commit/mirrors-prettier
3723
rev: v2.7.1
@@ -50,10 +36,10 @@ repos:
5036
language_version: python3
5137
additional_dependencies:
5238
- "poetry==1.2.0b2"
53-
- "Sphinx>=4,<5"
39+
- "Sphinx>=5,<8"
5440
- "sphinx-rtd-theme>=1,<2"
5541
- "sphinx-tabs>=3,<4"
56-
- "sphinx-toolbox==3.0.0"
42+
- "sphinx-toolbox>=3"
5743
- "git+https://github.com/octue/octue-sdk-python.git@main"
5844

5945
- repo: https://github.com/windpioneers/pre-commit-hooks

octue/cloud/pub_sub/logging.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def __init__(
3232
retry_count,
3333
timeout=60,
3434
*args,
35-
**kwargs
35+
**kwargs,
3636
):
3737
super().__init__(*args, **kwargs)
3838
self.question_uuid = question_uuid

octue/diagnostics.py

-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ def _upload_manifest(self, manifest_type, question_diagnostics_path):
176176

177177
# Upload each dataset and update its path in the manifest.
178178
for dataset_name, dataset_path in manifest["datasets"].items():
179-
180179
# Handle manifests containing serialised datasets instead of just the datasets' paths. Datasets can be in
181180
# this state when serialised if they were instantiated using the `files` argument.
182181
if isinstance(dataset_path, dict):

octue/essentials/monitor_messages.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""A module containing helper functions for sending monitor messages that conform to the Octue essential monitor
22
message schema https://jsonschema.registry.octue.com/octue/essential-monitors/0.0.2.json
33
"""
4+
45
import logging
56
from datetime import datetime, timezone
67

octue/mixins/filterable.py

-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ def _split_filter_name(self, filter_name):
156156
*attribute_names, filter_action = filter_name.split("__")
157157

158158
if not attribute_names:
159-
160159
raise exceptions.InvalidInputException(
161160
f"Invalid filter name {filter_name!r}. Filter names should be in the form "
162161
f"'<attribute_name_0>__<attribute_name_1>__<...>__<filter_kind>' with at least one attribute name "

octue/mixins/hashable.py

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818

1919
class Hashable:
20-
2120
_ATTRIBUTES_TO_HASH = None
2221
_HASH_TYPE = "CRC32C"
2322

octue/resources/datafile.py

-2
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ def cloud_path(self, path):
154154
:return None:
155155
"""
156156
if path is None:
157-
158157
if not self.exists_locally:
159158
raise CloudLocationNotSpecified(
160159
"The cloud path cannot be reset because this datafile only exists in the cloud."
@@ -732,7 +731,6 @@ def __exit__(self, *args):
732731
self._fp.close()
733732

734733
if any(character in self.mode for character in self.MODIFICATION_MODES):
735-
736734
if self.datafile.exists_in_cloud:
737735
self.datafile.upload(update_cloud_metadata=self._update_metadata)
738736

octue/resources/dataset.py

-2
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,6 @@ def add(self, datafile, path_in_dataset=None):
300300

301301
# Add a cloud datafile to a cloud dataset.
302302
if datafile.exists_in_cloud:
303-
304303
if datafile.cloud_path != new_cloud_path and not datafile.cloud_path.startswith(self.path):
305304
datafile.upload(new_cloud_path)
306305

@@ -350,7 +349,6 @@ def download(self, local_directory=None):
350349
datafiles_and_paths = []
351350

352351
for file in self.files:
353-
354352
if not file.exists_in_cloud:
355353
continue
356354

octue/resources/service_backends.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
the "oneOf" field of the "backend" key of the children schema in `Twined`, which is located at
66
`twined/schema/children_schema.json`.
77
"""
8+
89
from abc import ABC
910

1011
from octue import exceptions

octue/runner.py

-1
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,6 @@ def run(
250250
analysis_log_level=analysis_log_level,
251251
extra_log_handlers=extra_log_handlers,
252252
):
253-
254253
analysis = Analysis(
255254
id=analysis_id,
256255
twine=self.twine,

octue/templates/template-fractal/fractal/mandelbrot.py

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ def mandelbrot(width, height, x_range, y_range, n_iterations, c=None):
2626
# Simple loop to render the fractal set. This is not efficient python and would be vectorised in production, but the
2727
# purpose here is just to provide a simple demo.
2828
for idx, a in numpy.ndenumerate(x):
29-
3029
# Get default constant c (Mandelbrot sets use spatial coordinates as constants)
3130
if c is None:
3231
b = y[idx]

0 commit comments

Comments
 (0)