diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bad5af22c..a5e38f155 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 @@ -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"] @@ -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"] diff --git a/romancal/dark_current/tests/test_dark.py b/romancal/dark_current/tests/test_dark.py index 316063cb2..296264e0e 100644 --- a/romancal/dark_current/tests/test_dark.py +++ b/romancal/dark_current/tests/test_dark.py @@ -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 @@ -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:] @@ -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:] diff --git a/romancal/linearity/tests/test_linearity.py b/romancal/linearity/tests/test_linearity.py index 6b1fed838..bd34c6efa 100644 --- a/romancal/linearity/tests/test_linearity.py +++ b/romancal/linearity/tests/test_linearity.py @@ -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 diff --git a/romancal/resample/tests/test_resample.py b/romancal/resample/tests/test_resample.py index 78c9f7fbc..b20579f08 100644 --- a/romancal/resample/tests/test_resample.py +++ b/romancal/resample/tests/test_resample.py @@ -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, diff --git a/romancal/tweakreg/tests/test_tweakreg.py b/romancal/tweakreg/tests/test_tweakreg.py index 9929e3393..63dad8e5a 100644 --- a/romancal/tweakreg/tests/test_tweakreg.py +++ b/romancal/tweakreg/tests/test_tweakreg.py @@ -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, @@ -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): """ @@ -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])): @@ -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() @@ -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) @@ -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() @@ -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") @@ -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.""" @@ -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")