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

replace pyupgrade isort and black with ruff format #983

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
19 changes: 2 additions & 17 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,12 @@ 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
- id: ruff-format

- repo: https://github.com/PyCQA/bandit
rev: 1.7.5
Expand Down
27 changes: 7 additions & 20 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still is not selecting the rules for ruff to replace the pre-commit tooling this PR claims to be replacing. I'll open a PR against your branch fixing these issues.


[tool.ruff.extend-per-file-ignores]
"romancal/associations/__init__.py" = ["E402"]
Expand Down
14 changes: 6 additions & 8 deletions romancal/associations/tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
4 changes: 1 addition & 3 deletions romancal/ramp_fitting/ramp_fit_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion romancal/refpix/tests/reference_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions romancal/resample/gwcs_drizzle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions romancal/skymatch/skymatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Loading