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

Manual Pre-commit update #1462

Merged
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
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ exclude: ".*\\.asdf$"
repos:

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-ast
Expand All @@ -28,13 +28,13 @@ repos:
- id: text-unicode-replacement-char

- repo: https://github.com/asottile/pyupgrade
rev: 'v3.15.1'
rev: 'v3.18.0'
hooks:
- id: pyupgrade
args: ["--py38-plus"]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.2.2'
rev: 'v0.6.9'
hooks:
- id: ruff
args: ["--fix"]
Expand All @@ -45,12 +45,12 @@ repos:
- id: isort

- repo: https://github.com/psf/black
rev: 24.2.0
rev: 24.10.0
hooks:
- id: black

- repo: https://github.com/PyCQA/bandit
rev: 1.7.7
rev: 1.7.10
hooks:
- id: bandit
args: ["-c", "pyproject.toml"]
Expand Down
6 changes: 3 additions & 3 deletions romancal/dark_current/tests/test_dark.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_dark_step_interface(instrument, exptype):

# Test dark results
assert (result.data == ramp_model.data).all()
assert type(result) == RampModel
assert isinstance(result, RampModel)
assert result.validate() is None
assert result.data.shape == shape
assert result.groupdq.shape == shape
Expand Down Expand Up @@ -99,7 +99,7 @@ def test_dark_step_output_dark_file(tmp_path, instrument, exptype):
dark_out_file_model = rdm.open(path)

# Test dark file results
assert type(dark_out_file_model) == DarkRefModel
assert isinstance(dark_out_file_model, DarkRefModel)
assert dark_out_file_model.validate() is None
assert dark_out_file_model.data.shape == shape
assert dark_out_file_model.dq.shape == shape[1:]
Expand Down Expand Up @@ -132,7 +132,7 @@ def test_dark_step_getbestrefs(tmp_path, instrument, exptype):
dark_out_file_model = rdm.open(path)

# Test dark file results
assert type(dark_out_file_model) == DarkRefModel
assert isinstance(dark_out_file_model, DarkRefModel)
assert dark_out_file_model.validate() is None
assert dark_out_file_model.data.shape == shape
assert dark_out_file_model.dq.shape == shape[1:]
Expand Down
3 changes: 1 addition & 2 deletions romancal/linearity/tests/test_linearity.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@

import numpy as np
import pytest
from roman_datamodels import maker_utils
from roman_datamodels import dqflags, maker_utils
from roman_datamodels.datamodels import LinearityRefModel, ScienceRawModel

from romancal.dq_init import DQInitStep
from romancal.lib import dqflags
from romancal.linearity import LinearityStep


Expand Down
4 changes: 1 addition & 3 deletions romancal/resample/tests/test_resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,9 @@ def test_resampledata_init_default(exposure_1):
@pytest.mark.parametrize("input_models", [list()])
def test_resampledata_init_invalid_input(input_models):
"""Test that ResampleData will raise an exception on invalid inputs."""
with pytest.raises(Exception) as exec_info:
with pytest.raises(ValueError):
ResampleData(input_models)

assert type(exec_info.value) == ValueError


def test_resampledata_do_drizzle_many_to_one_default_no_rotation_single_exposure(
exposure_1,
Expand Down
22 changes: 9 additions & 13 deletions romancal/tweakreg/tests/test_tweakreg.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ def test_tweakreg_raises_error_on_invalid_abs_refcat(tmp_path, base_image):
img = base_image(shift_1=1000, shift_2=1000)
add_tweakreg_catalog_attribute(tmp_path, img)

with pytest.raises(Exception) as exec_info:
with pytest.raises(TypeError):
trs.TweakRegStep.call(
[img],
save_abs_catalog=True,
Expand All @@ -695,8 +695,6 @@ def test_tweakreg_raises_error_on_invalid_abs_refcat(tmp_path, base_image):
output_dir=str(tmp_path),
)

assert type(exec_info.value) == TypeError


def test_tweakreg_combine_custom_catalogs_and_asn_file(tmp_path, base_image):
"""
Expand Down Expand Up @@ -737,7 +735,7 @@ def test_tweakreg_combine_custom_catalogs_and_asn_file(tmp_path, base_image):
catfile=catfile,
)

assert type(res) == ModelLibrary
assert isinstance(res, ModelLibrary)

with res:
for i, (model, target) in enumerate(zip(res, [img1, img2, img3])):
Expand All @@ -750,7 +748,7 @@ def test_tweakreg_combine_custom_catalogs_and_asn_file(tmp_path, base_image):

assert model.meta.filename == target.meta.filename

assert type(model) == type(target)
assert type(model) is type(target)

assert (model.data == target.data).all()

Expand Down Expand Up @@ -853,7 +851,7 @@ def test_tweakreg_parses_asn_correctly(tmp_path, base_image):

res = trs.TweakRegStep.call(asn_filepath)

assert type(res) == ModelLibrary
assert isinstance(res, ModelLibrary)

with res:
models = list(res)
Expand All @@ -872,8 +870,8 @@ def test_tweakreg_parses_asn_correctly(tmp_path, base_image):
assert models[0].meta.filename == img_1.meta.filename
assert models[1].meta.filename == img_2.meta.filename

assert type(models[0]) == type(img_1)
assert type(models[1]) == type(img_2)
assert type(models[0]) is type(img_1)
assert type(models[1]) is type(img_2)

assert (models[0].data == img_1.data).all()
assert (models[1].data == img_2.data).all()
Expand All @@ -891,7 +889,7 @@ def test_fit_results_in_meta(tmp_path, base_image):

res = trs.TweakRegStep.call([img])

assert type(res) == ModelLibrary
assert isinstance(res, ModelLibrary)
with res:
for i, model in enumerate(res):
assert hasattr(model.meta, "wcs_fit_results")
Expand Down Expand Up @@ -995,11 +993,9 @@ def test_parse_catfile_raises_error_on_invalid_content(tmp_path, catfile_line_co
with open(catfile, mode="w") as f:
print(catfile_content.getvalue(), file=f)

with pytest.raises(Exception) as exec_info:
with pytest.raises(ValueError):
trs._parse_catfile(catfile)

assert type(exec_info.value) == ValueError


def test_update_source_catalog_coordinates(tmp_path, base_image):
"""Test that TweakReg updates the catalog coordinates with the tweaked WCS."""
Expand Down Expand Up @@ -1234,7 +1230,7 @@ def test_tweakreg_skips_invalid_exposure_types(exposure_type, tmp_path, base_ima
img2.meta.exposure.type = exposure_type
res = trs.TweakRegStep.call([img1, img2])

assert type(res) == ModelLibrary
assert isinstance(res, ModelLibrary)
with res:
for i, model in enumerate(res):
assert hasattr(model.meta.cal_step, "tweakreg")
Expand Down