Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-48788: Switch to ruff format #106

Merged
merged 7 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions .github/workflows/lint.yaml

This file was deleted.

18 changes: 3 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,13 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-toml
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.10.0
hooks:
- id: black
# It is recommended to specify the latest version of Python
# supported by your project here, or alternatively use
# pre-commit's default_language_version, see
# https://pre-commit.com/#top_level-default_language_version
language_version: python3.11
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
name: isort (python)
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.7.4
rev: v0.9.4
hooks:
- id: ruff
args: [--fix]
- id: ruff-format
- repo: https://github.com/numpy/numpydoc
rev: "v1.8.0"
hooks:
Expand Down
10 changes: 10 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ target-version = ["py311"]
[tool.isort]
profile = "black"
line_length = 110
known_first_party = ["lsst"]

[tool.lsst_versions]
write_to = "python/lsst/resources/version.py"
Expand Down Expand Up @@ -167,17 +168,26 @@ select = [
"D", # pydocstyle
"UP", # pyupgrade
"C4",
"I", # isort
"RUF022", # __all__ sorting
]
extend-select = [
"RUF100", # Warn about unused noqa
]

[tool.ruff.lint.isort]
known-first-party = ["lsst"]

[tool.ruff.lint.pycodestyle]
max-doc-length = 79

[tool.ruff.lint.pydocstyle]
convention = "numpy"

[tool.ruff.format]
docstring-code-format = true
docstring-code-line-length = 79

[tool.numpydoc_validation]
checks = [
"all", # All except the rules listed below.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from typing import TYPE_CHECKING, AnyStr, NamedTuple

import requests

from lsst.utils.timer import time_this

from ._baseResourceHandle import BaseResourceHandle, CloseStatus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from typing import TYPE_CHECKING

from botocore.exceptions import ClientError

from lsst.utils.introspection import find_outside_stacklevel
from lsst.utils.timer import time_this

Expand Down
3 changes: 2 additions & 1 deletion python/lsst/resources/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@

import requests
from astropy import units as u
from lsst.utils.timer import time_this
from requests.adapters import HTTPAdapter
from requests.auth import AuthBase
from urllib3.util.retry import Retry

from lsst.utils.timer import time_this

from ._resourceHandles import ResourceHandleProtocol
from ._resourceHandles._httpResourceHandle import HttpReadResourceHandle, parse_content_range_header
from ._resourcePath import ResourcePath
Expand Down
3 changes: 2 additions & 1 deletion python/lsst/resources/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from typing import IO, TYPE_CHECKING, cast

from botocore.exceptions import ClientError

from lsst.utils.timer import time_this

from ._resourceHandles._baseResourceHandle import ResourceHandleProtocol
Expand Down Expand Up @@ -258,7 +259,7 @@ def remove(self) -> None:
def read(self, size: int = -1) -> bytes:
args = {}
if size > 0:
args["Range"] = f"bytes=0-{size-1}"
args["Range"] = f"bytes=0-{size - 1}"
try:
response = self.client.get_object(Bucket=self._bucket, Key=self.relativeToPathRoot, **args)
except (self.client.exceptions.NoSuchKey, self.client.exceptions.NoSuchBucket) as err:
Expand Down
14 changes: 7 additions & 7 deletions python/lsst/resources/s3utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
from __future__ import annotations

__all__ = (
"getS3Client",
"s3CheckFileExists",
"bucketExists",
"backoff",
"_TooManyRequestsError",
"all_retryable_errors",
"backoff",
"bucketExists",
"clean_test_environment_for_s3",
"getS3Client",
"max_retry_time",
"retryable_io_errors",
"retryable_client_errors",
"_TooManyRequestsError",
"clean_test_environment_for_s3",
"retryable_io_errors",
"s3CheckFileExists",
)

import functools
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/resources/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# license that can be found in the LICENSE file.
from __future__ import annotations

__all__ = ["GenericTestCase", "GenericReadWriteTestCase"]
__all__ = ["GenericReadWriteTestCase", "GenericTestCase"]

import logging
import os
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/resources/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from __future__ import annotations

__all__ = ("os2posix", "posix2os", "NoTransaction", "TransactionProtocol")
__all__ = ("NoTransaction", "TransactionProtocol", "os2posix", "posix2os")

import contextlib
import logging
Expand Down
3 changes: 2 additions & 1 deletion tests/test_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@
except ImportError:
WsgiDAVApp = None

import lsst.resources
import requests
import responses

import lsst.resources
from lsst.resources import ResourcePath
from lsst.resources._resourceHandles._httpResourceHandle import (
HttpReadResourceHandle,
Expand Down
3 changes: 2 additions & 1 deletion tests/test_s3utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
except ImportError:
boto3 = None

from urllib3.exceptions import LocationParseError

from lsst.resources import ResourcePath
from lsst.resources.location import Location
from lsst.resources.s3utils import (
Expand All @@ -43,7 +45,6 @@
getS3Client,
s3CheckFileExists,
)
from urllib3.exceptions import LocationParseError


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