Skip to content

Commit

Permalink
Merge pull request #324 from lsst/tickets/DM-48788
Browse files Browse the repository at this point in the history
DM-48788: Switch to ruff format
  • Loading branch information
timj authored Feb 7, 2025
2 parents 92a3ef2 + a61e7f9 commit 0f3ec9b
Show file tree
Hide file tree
Showing 19 changed files with 36 additions and 40 deletions.
16 changes: 0 additions & 16 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: 25.1.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: 6.0.0
hooks:
- id: isort
name: isort (python)
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.9.3
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
11 changes: 11 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ target-version = ["py311"]
[tool.isort]
profile = "black"
line_length = 110
known_first_party = ["lsst"]

[tool.lsst_versions]
write_to = "python/lsst/ctrl/mpexec/version.py"
Expand Down Expand Up @@ -162,17 +163,27 @@ select = [
"N", # pep8-naming
"W", # pycodestyle
"D", # pydocstyle
"I", # isort
"UP", # pyupgrade
]
extend-select = [
"RUF022", # Sort __all__
"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
1 change: 1 addition & 0 deletions python/lsst/ctrl/mpexec/cli/cmd/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from typing import Any

import click

import lsst.pipe.base.cli.opt as pipeBaseOpts
from lsst.ctrl.mpexec import Report
from lsst.ctrl.mpexec.showInfo import ShowInfo
Expand Down
1 change: 1 addition & 0 deletions python/lsst/ctrl/mpexec/cli/opt/optionGroups.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@


import click

import lsst.daf.butler.cli.opt as dafButlerOpts
import lsst.pipe.base.cli.opt as pipeBaseOpts
from lsst.daf.butler.cli.opt import transfer_option_no_short
Expand Down
1 change: 1 addition & 0 deletions python/lsst/ctrl/mpexec/cli/opt/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from typing import TYPE_CHECKING

import click

from lsst.daf.butler.cli.utils import MWOptionDecorator, MWPath, split_commas, unwrap
from lsst.utils.doImport import doImportType

Expand Down
1 change: 1 addition & 0 deletions python/lsst/ctrl/mpexec/cli/pipetask.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import click

from lsst.daf.butler.cli.butler import LoaderCLI
from lsst.daf.butler.cli.opt import (
log_file_option,
Expand Down
1 change: 1 addition & 0 deletions python/lsst/ctrl/mpexec/cli/script/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from collections.abc import Sequence

from astropy.table import Table

from lsst.daf.butler import Butler
from lsst.pipe.base import QuantumGraph, QuantumSuccessCaveats
from lsst.pipe.base.execution_reports import QuantumGraphExecutionReport
Expand Down
3 changes: 2 additions & 1 deletion python/lsst/ctrl/mpexec/cmdLineFwk.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@
from types import SimpleNamespace

import astropy.units as u
import lsst.utils.timer
from astropy.table import Table

import lsst.utils.timer
from lsst.daf.butler import (
Butler,
CollectionType,
Expand Down
1 change: 1 addition & 0 deletions python/lsst/ctrl/mpexec/dotTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
from typing import Any

from deprecated.sphinx import deprecated

from lsst.pipe.base import Pipeline, QuantumGraph, TaskDef
from lsst.pipe.base.dot_tools import graph2dot as _graph2dot
from lsst.pipe.base.dot_tools import pipeline2dot as _pipeline2dot
Expand Down
7 changes: 5 additions & 2 deletions python/lsst/ctrl/mpexec/execFixupDataId.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from typing import Any

import networkx as nx

from lsst.pipe.base import QuantumGraph, QuantumNode

from .executionGraphFixup import ExecutionGraphFixup
Expand All @@ -51,9 +52,11 @@ class ExecFixupDataId(ExecutionGraphFixup):
from lsst.ctrl.mpexec.execFixupDataId import ExecFixupDataId
def assoc_fixup():
return ExecFixupDataId(taskLabel="ap_assoc",
dimensions=("visit", "detector"))
return ExecFixupDataId(
taskLabel="ap_assoc", dimensions=("visit", "detector")
)
and then executing pipetask::
Expand Down
3 changes: 2 additions & 1 deletion python/lsst/ctrl/mpexec/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@

from __future__ import annotations

__all__ = ["ExceptionInfo", "ExecutionStatus", "Report", "QuantumReport"]
__all__ = ["ExceptionInfo", "ExecutionStatus", "QuantumReport", "Report"]

import enum
import sys
from typing import Any

import pydantic

from lsst.daf.butler import DataCoordinate, DataId, DataIdValue
from lsst.pipe.base import QgraphSummary
from lsst.utils.introspection import get_full_type_name
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/ctrl/mpexec/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

"""Few utility methods used by the rest of a package."""

__all__ = ["printTable", "filterTaskNodes", "subTaskIter"]
__all__ = ["filterTaskNodes", "printTable", "subTaskIter"]

from collections.abc import Iterator

Expand Down
1 change: 0 additions & 1 deletion tests/test_cliCmdCleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

"""Unit tests for ctrl_mpexec CLI cleanup subcommand."""


import os
import unittest

Expand Down
1 change: 0 additions & 1 deletion tests/test_cliCmdPurge.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

"""Unit tests for ctrl_mpexec CLI purge subcommand."""


import os
import unittest

Expand Down
5 changes: 3 additions & 2 deletions tests/test_cliCmdReport.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@
import unittest

import yaml
from yaml.loader import SafeLoader

from lsst.ctrl.mpexec.cli.pipetask import cli as pipetask_cli
from lsst.ctrl.mpexec.cli.script.report import print_summary
from lsst.daf.butler.cli.utils import LogCliRunner, clickResultMsg
from lsst.daf.butler.tests.utils import makeTestTempDir, removeTestTempDir
from lsst.pipe.base.quantum_provenance_graph import Summary
from lsst.pipe.base.tests.simpleQGraph import makeSimpleQGraph
from lsst.pipe.base.tests.util import check_output_run
from yaml.loader import SafeLoader

TESTDIR = os.path.abspath(os.path.dirname(__file__))

Expand Down Expand Up @@ -302,7 +303,7 @@ def test_aggregate_reports(self):

self.assertEqual(report1.exit_code, 0, clickResultMsg(report1))
# Now, copy the json output into a duplicate file and aggregate
with open(file1, "r") as f:
with open(file1) as f:
sum1 = Summary.model_validate_json(f.read())
sum2 = sum1.model_copy(deep=True)
print_summary(sum2, file2, brief=False)
Expand Down
1 change: 1 addition & 0 deletions tests/test_cliScript.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import unittest.mock

import click

import lsst.utils.tests
from lsst.ctrl.mpexec.cli import opt, script
from lsst.ctrl.mpexec.cli.cmd.commands import coverage_context
Expand Down
1 change: 1 addition & 0 deletions tests/test_cmdLineFwk.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

import astropy.units as u
import click

import lsst.pex.config as pexConfig
import lsst.pipe.base.connectionTypes as cT
import lsst.utils.tests
Expand Down
1 change: 1 addition & 0 deletions tests/test_executors.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

import networkx as nx
import psutil

from lsst.ctrl.mpexec import (
ExecutionStatus,
MPGraphExecutor,
Expand Down

0 comments on commit 0f3ec9b

Please sign in to comment.