From 2c66e1273ddd2225f5a27fd6a3add621cf82bfbb Mon Sep 17 00:00:00 2001 From: zacharyburnett Date: Wed, 8 Nov 2023 13:31:23 -0500 Subject: [PATCH 1/3] replace `pyupgrade` `isort` and `black` with `ruff format` --- .pre-commit-config.yaml | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 055fe493b..e286cac14 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,31 +25,9 @@ repos: - id: rst-inline-touching-normal - id: text-unicode-replacement-char -- repo: https://github.com/asottile/pyupgrade - rev: 'v3.15.0' - hooks: - - id: pyupgrade - args: ["--py38-plus"] - - repo: https://github.com/astral-sh/ruff-pre-commit - rev: 'v0.1.4' + rev: v0.1.4 hooks: - id: ruff args: ["--fix"] - -- repo: https://github.com/pycqa/isort - rev: 5.12.0 - hooks: - - id: isort - -- repo: https://github.com/psf/black - rev: 23.10.1 - hooks: - - id: black - -- repo: https://github.com/PyCQA/bandit - rev: 1.7.5 - hooks: - - id: bandit - args: ["-c", "pyproject.toml"] - additional_dependencies: ["bandit[toml]"] + - id: ruff-format From 33749572da828fdb251de5eb82846d9c846cca37 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 8 Nov 2023 18:33:15 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- romancal/associations/tests/helpers.py | 14 ++++++-------- romancal/ramp_fitting/ramp_fit_step.py | 4 +--- romancal/refpix/tests/reference_utils.py | 2 +- romancal/resample/gwcs_drizzle.py | 4 +--- romancal/skymatch/skymatch.py | 5 +++-- 5 files changed, 12 insertions(+), 17 deletions(-) diff --git a/romancal/associations/tests/helpers.py b/romancal/associations/tests/helpers.py index b886db206..8f45f46b1 100644 --- a/romancal/associations/tests/helpers.py +++ b/romancal/associations/tests/helpers.py @@ -64,10 +64,9 @@ def test_run_generate(self): for ppars in self.pools: pool = combine_pools(ppars.path, **ppars.kwargs) asns = generate(pool, rules) - assert ( - len(asns) == ppars.n_asns - ), ppars.path + ": n_asns not expected {} {}".format( - len(asns), ppars.n_asns + assert len(asns) == ppars.n_asns, ( + ppars.path + + ": n_asns not expected {} {}".format(len(asns), ppars.n_asns) ) for asn, candidates in zip(asns, ppars.candidates): assert set(asn.candidates) == set(candidates) @@ -77,10 +76,9 @@ def test_run_generate(self): for member in product["members"]: if member["exptype"] == "science": match = file_regex.match(member["expname"]) - assert ( - match is not None - ), ppars.path + ": No suffix match for {}".format( - member["expname"] + assert match is not None, ( + ppars.path + + ": No suffix match for {}".format(member["expname"]) ) assert ( match.groupdict()["suffix"] in ppars.valid_suffixes diff --git a/romancal/ramp_fitting/ramp_fit_step.py b/romancal/ramp_fitting/ramp_fit_step.py index 0dfb8eef6..ecc3d7d69 100644 --- a/romancal/ramp_fitting/ramp_fit_step.py +++ b/romancal/ramp_fitting/ramp_fit_step.py @@ -251,9 +251,7 @@ def create_image_model(input_model, image_info): var_poisson = u.Quantity( var_poisson, u.electron**2 / u.s**2, dtype=var_poisson.dtype ) - var_rnoise = u.Quantity( - var_rnoise, u.electron**2 / u.s**2, dtype=var_rnoise.dtype - ) + var_rnoise = u.Quantity(var_rnoise, u.electron**2 / u.s**2, dtype=var_rnoise.dtype) err = u.Quantity(err, u.electron / u.s, dtype=err.dtype) if dq is None: dq = np.zeros(data.shape, dtype="u4") diff --git a/romancal/refpix/tests/reference_utils.py b/romancal/refpix/tests/reference_utils.py index 17bc2cc3d..18c02ba59 100644 --- a/romancal/refpix/tests/reference_utils.py +++ b/romancal/refpix/tests/reference_utils.py @@ -308,7 +308,7 @@ def fft_interp( # meaningfully chanFrameData_Flat = spfft.irfft( fftResult * chanFrameData_Flat.size, - workers=1 + workers=1, # ) ).astype(chanFrameData_Flat.dtype) # Return read only pixels diff --git a/romancal/resample/gwcs_drizzle.py b/romancal/resample/gwcs_drizzle.py index dc7999507..10ce1581e 100644 --- a/romancal/resample/gwcs_drizzle.py +++ b/romancal/resample/gwcs_drizzle.py @@ -94,9 +94,7 @@ def __init__( elif self.outcon.ndim != 3: raise ValueError( "Drizzle context image has wrong dimensions: \ - {}".format( - product - ) + {}".format(product) ) # Check field values diff --git a/romancal/skymatch/skymatch.py b/romancal/skymatch/skymatch.py index 8ac63e16d..8980a9c2a 100644 --- a/romancal/skymatch/skymatch.py +++ b/romancal/skymatch/skymatch.py @@ -403,8 +403,9 @@ def _apply_sky(images, sky_deltas, do_global, do_skysub, show_old): # log sky values: log.info( - " * Group ID={}. Sky background of " - "component images:".format(img.id) + " * Group ID={}. Sky background of " "component images:".format( + img.id + ) ) for im, old_sky, new_sky in zip(img, old_img_sky, new_img_sky): From abeb8109c5834b4adabc0e975759d84f0d9ff2e6 Mon Sep 17 00:00:00 2001 From: zacharyburnett Date: Thu, 9 Nov 2023 14:42:20 -0500 Subject: [PATCH 3/3] change tool configuration --- .pre-commit-config.yaml | 7 +++++++ pyproject.toml | 27 +++++++-------------------- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e286cac14..cf5ffa949 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -31,3 +31,10 @@ repos: - id: ruff args: ["--fix"] - id: ruff-format + +- repo: https://github.com/PyCQA/bandit + rev: 1.7.5 + hooks: + - id: bandit + args: ["-c", "pyproject.toml"] + additional_dependencies: ["bandit[toml]"] diff --git a/pyproject.toml b/pyproject.toml index 7168ce445..9c8d99b84 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -166,36 +166,23 @@ report = { exclude_lines = [ [tool.bandit] skips = ["B101", "B307", "B404", "B603"] -[tool.isort] -profile = "black" -filter_files = true -line_length = 88 - -[tool.black] -line-length = 88 -force-exclude = ''' -^/( - ( - \.eggs - | \.git - | \.pytest_cache - | \.tox - )/ -) -''' - [tool.ruff] line-length = 88 exclude = [ - 'jdocs', - '.tox', '.eggs', + '.git', + '.pytest_cache', + '.tox', + 'jdocs', 'build', ] ignore = [ 'E741', # ambiguous variable name ] extend-select = ['NPY'] +extend-include = ["*.ipynb"] + +[tool.ruff.lint.isort] [tool.ruff.extend-per-file-ignores] "romancal/associations/__init__.py" = ["E402"]