Skip to content

Commit 2cf0f8f

Browse files
authored
Merge pull request #106 from lsst/tickets/DM-48788
DM-48788: Switch to ruff format
2 parents c989d23 + f0cfc68 commit 2cf0f8f

File tree

12 files changed

+32
-42
lines changed

12 files changed

+32
-42
lines changed

.github/workflows/lint.yaml

-14
This file was deleted.

.pre-commit-config.yaml

+3-15
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,13 @@ repos:
66
- id: end-of-file-fixer
77
- id: trailing-whitespace
88
- id: check-toml
9-
- repo: https://github.com/psf/black-pre-commit-mirror
10-
rev: 24.10.0
11-
hooks:
12-
- id: black
13-
# It is recommended to specify the latest version of Python
14-
# supported by your project here, or alternatively use
15-
# pre-commit's default_language_version, see
16-
# https://pre-commit.com/#top_level-default_language_version
17-
language_version: python3.11
18-
- repo: https://github.com/pycqa/isort
19-
rev: 5.13.2
20-
hooks:
21-
- id: isort
22-
name: isort (python)
239
- repo: https://github.com/astral-sh/ruff-pre-commit
2410
# Ruff version.
25-
rev: v0.7.4
11+
rev: v0.9.4
2612
hooks:
2713
- id: ruff
14+
args: [--fix]
15+
- id: ruff-format
2816
- repo: https://github.com/numpy/numpydoc
2917
rev: "v1.8.0"
3018
hooks:

pyproject.toml

+10
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ target-version = ["py311"]
107107
[tool.isort]
108108
profile = "black"
109109
line_length = 110
110+
known_first_party = ["lsst"]
110111

111112
[tool.lsst_versions]
112113
write_to = "python/lsst/resources/version.py"
@@ -167,17 +168,26 @@ select = [
167168
"D", # pydocstyle
168169
"UP", # pyupgrade
169170
"C4",
171+
"I", # isort
172+
"RUF022", # __all__ sorting
170173
]
171174
extend-select = [
172175
"RUF100", # Warn about unused noqa
173176
]
174177

178+
[tool.ruff.lint.isort]
179+
known-first-party = ["lsst"]
180+
175181
[tool.ruff.lint.pycodestyle]
176182
max-doc-length = 79
177183

178184
[tool.ruff.lint.pydocstyle]
179185
convention = "numpy"
180186

187+
[tool.ruff.format]
188+
docstring-code-format = true
189+
docstring-code-line-length = 79
190+
181191
[tool.numpydoc_validation]
182192
checks = [
183193
"all", # All except the rules listed below.

python/lsst/resources/_resourceHandles/_httpResourceHandle.py

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from typing import TYPE_CHECKING, AnyStr, NamedTuple
2121

2222
import requests
23+
2324
from lsst.utils.timer import time_this
2425

2526
from ._baseResourceHandle import BaseResourceHandle, CloseStatus

python/lsst/resources/_resourceHandles/_s3ResourceHandle.py

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from typing import TYPE_CHECKING
2121

2222
from botocore.exceptions import ClientError
23+
2324
from lsst.utils.introspection import find_outside_stacklevel
2425
from lsst.utils.timer import time_this
2526

python/lsst/resources/http.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,12 @@
5151

5252
import requests
5353
from astropy import units as u
54-
from lsst.utils.timer import time_this
5554
from requests.adapters import HTTPAdapter
5655
from requests.auth import AuthBase
5756
from urllib3.util.retry import Retry
5857

58+
from lsst.utils.timer import time_this
59+
5960
from ._resourceHandles import ResourceHandleProtocol
6061
from ._resourceHandles._httpResourceHandle import HttpReadResourceHandle, parse_content_range_header
6162
from ._resourcePath import ResourcePath

python/lsst/resources/s3.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from typing import IO, TYPE_CHECKING, cast
2626

2727
from botocore.exceptions import ClientError
28+
2829
from lsst.utils.timer import time_this
2930

3031
from ._resourceHandles._baseResourceHandle import ResourceHandleProtocol
@@ -258,7 +259,7 @@ def remove(self) -> None:
258259
def read(self, size: int = -1) -> bytes:
259260
args = {}
260261
if size > 0:
261-
args["Range"] = f"bytes=0-{size-1}"
262+
args["Range"] = f"bytes=0-{size - 1}"
262263
try:
263264
response = self.client.get_object(Bucket=self._bucket, Key=self.relativeToPathRoot, **args)
264265
except (self.client.exceptions.NoSuchKey, self.client.exceptions.NoSuchBucket) as err:

python/lsst/resources/s3utils.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@
1212
from __future__ import annotations
1313

1414
__all__ = (
15-
"getS3Client",
16-
"s3CheckFileExists",
17-
"bucketExists",
18-
"backoff",
15+
"_TooManyRequestsError",
1916
"all_retryable_errors",
17+
"backoff",
18+
"bucketExists",
19+
"clean_test_environment_for_s3",
20+
"getS3Client",
2021
"max_retry_time",
21-
"retryable_io_errors",
2222
"retryable_client_errors",
23-
"_TooManyRequestsError",
24-
"clean_test_environment_for_s3",
23+
"retryable_io_errors",
24+
"s3CheckFileExists",
2525
)
2626

2727
import functools

python/lsst/resources/tests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# license that can be found in the LICENSE file.
1111
from __future__ import annotations
1212

13-
__all__ = ["GenericTestCase", "GenericReadWriteTestCase"]
13+
__all__ = ["GenericReadWriteTestCase", "GenericTestCase"]
1414

1515
import logging
1616
import os

python/lsst/resources/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
from __future__ import annotations
1313

14-
__all__ = ("os2posix", "posix2os", "NoTransaction", "TransactionProtocol")
14+
__all__ = ("NoTransaction", "TransactionProtocol", "os2posix", "posix2os")
1515

1616
import contextlib
1717
import logging

tests/test_http.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@
3131
except ImportError:
3232
WsgiDAVApp = None
3333

34-
import lsst.resources
3534
import requests
3635
import responses
36+
37+
import lsst.resources
3738
from lsst.resources import ResourcePath
3839
from lsst.resources._resourceHandles._httpResourceHandle import (
3940
HttpReadResourceHandle,

tests/test_s3utils.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
except ImportError:
3535
boto3 = None
3636

37+
from urllib3.exceptions import LocationParseError
38+
3739
from lsst.resources import ResourcePath
3840
from lsst.resources.location import Location
3941
from lsst.resources.s3utils import (
@@ -43,7 +45,6 @@
4345
getS3Client,
4446
s3CheckFileExists,
4547
)
46-
from urllib3.exceptions import LocationParseError
4748

4849

4950
@unittest.skipIf(not boto3, "Warning: boto3 AWS SDK not found!")

0 commit comments

Comments
 (0)