Skip to content

Commit

Permalink
Upgrade pre-commits ruff 0.8.3 -> 0.8.6
Browse files Browse the repository at this point in the history
  • Loading branch information
larsevj committed Jan 6, 2025
1 parent 790933d commit 3f8b320
Show file tree
Hide file tree
Showing 25 changed files with 38 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repos:
exclude: test-data/ert/eclipse/parse/ERROR.PRT # exact format is needed for testing

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.3
rev: v0.8.6
hooks:
- id: ruff
args: [ --fix ]
Expand Down
4 changes: 2 additions & 2 deletions src/ert/services/webviz_ert_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ class WebvizErt(BaseService):

def __init__(self, **kwargs: Any):
exec_args = [sys.executable, "-m", "webviz_ert"]
if kwargs.get("experimental_mode", False):
if kwargs.get("experimental_mode"):
exec_args.append("--experimental-mode")
if kwargs.get("verbose", False):
if kwargs.get("verbose"):
exec_args.append("--verbose")
exec_args.extend(["--title", str(kwargs.get("title"))])
project = kwargs.get("project")
Expand Down
4 changes: 2 additions & 2 deletions tests/ert/ui_tests/cli/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
@pytest.mark.filterwarnings("ignore::ert.config.ConfigWarning")
def test_bad_config_error_message(tmp_path):
(tmp_path / "test.ert").write_text("NUM_REL 10\n")
with pytest.raises(ConfigValidationError, match="NUM_REALIZATIONS must be set."):
with pytest.raises(ConfigValidationError, match="NUM_REALIZATIONS must be set\\."):
run_cli(TEST_RUN_MODE, "--disable-monitor", str(tmp_path / "test.ert"))


Expand Down Expand Up @@ -548,7 +548,7 @@ def test_that_stop_on_fail_workflow_jobs_stop_ert(
)

if expect_stopped:
with pytest.raises(Exception, match="Workflow job .* failed with error"):
with pytest.raises(Exception, match=r"Workflow job .* failed with error"):
run_cli(TEST_RUN_MODE, "--disable-monitor", "poly.ert")
else:
run_cli(TEST_RUN_MODE, "--disable-monitor", "poly.ert")
Expand Down
4 changes: 2 additions & 2 deletions tests/ert/unit_tests/config/parsing/test_lark_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,13 @@ def test_include_cyclical_raises_error():
with open(test_include_file_name, "w", encoding="utf-8") as fh:
fh.write(test_include_contents)

with pytest.raises(ConfigValidationError, match="Cyclical .*test.ert"):
with pytest.raises(ConfigValidationError, match=r"Cyclical .*test.ert"):
_ = parse(test_config_file_name, schema=init_user_config_schema())

# Test self include raises cyclical include error
with open(test_config_file_name, "w", encoding="utf-8") as fh:
fh.write(test_config_self_include)
with pytest.raises(ConfigValidationError, match="Cyclical .*test.ert->test.ert"):
with pytest.raises(ConfigValidationError, match=r"Cyclical .*test.ert->test.ert"):
_ = parse(test_config_file_name, schema=init_user_config_schema())


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def test_parse(file_contents):
def test_that_unexpected_character_gives_observation_config_error():
with pytest.raises(
ObservationConfigError,
match="Line 1.*include a;",
match=r"Line 1.*include a;",
):
_parse_content(content="include a;", filename="")

Expand Down
2 changes: 1 addition & 1 deletion tests/ert/unit_tests/config/test_analysis_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def test_invalid_min_realization_raises_config_validation_error():
def test_invalid_design_matrix_format_raises_validation_error():
with pytest.raises(
ConfigValidationError,
match="DESIGN_MATRIX must be of format .xls or .xlsx; is 'my_matrix.txt'",
match="DESIGN_MATRIX must be of format \\.xls or \\.xlsx; is 'my_matrix\\.txt'",
):
AnalysisConfig.from_dict(
{
Expand Down
2 changes: 1 addition & 1 deletion tests/ert/unit_tests/config/test_ert_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1163,7 +1163,7 @@ def test_that_failing_to_load_ert_script_with_errors_fails_gracefully(load_state
def test_that_define_statements_with_less_than_one_argument_raises_error():
with pytest.raises(
ConfigValidationError,
match="DEFINE must have (two or more|at least 2) arguments",
match=r"DEFINE must have (two or more|at least 2) arguments",
):
_ = ErtConfig.from_file_contents(
dedent(
Expand Down
2 changes: 1 addition & 1 deletion tests/ert/unit_tests/config/test_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def test_invalid_forward_init_gives_a_user_error_message(parse_field_line, inval
def test_missing_init_files_gives_a_user_error_message(parse_field_line):
with pytest.raises(
ConfigValidationError,
match="Line 3.*Missing required INIT_FILES for field 'foo'",
match=r"Line 3.*Missing required INIT_FILES for field 'foo'",
):
_ = parse_field_line("FIELD foo parameter bar.roff")

Expand Down
4 changes: 2 additions & 2 deletions tests/ert/unit_tests/config/test_forward_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ def validate_pre_realization_run(

with pytest.raises(
ConfigValidationError,
match=".*This is a bad forward model step, dont use it.*",
match=r".*This is a bad forward model step, dont use it.*",
):
create_forward_model_json(
context=config.substitutions,
Expand Down Expand Up @@ -932,7 +932,7 @@ def validate_pre_experiment(self, fm_step_json: ForwardModelStepJSON) -> None:

raise ForwardModelStepValidationError("well that's nice")

with pytest.raises(ConfigValidationError, match=".*hamster style.*that's nice.*"):
with pytest.raises(ConfigValidationError, match=r".*hamster style.*that's nice.*"):
_ = ErtConfig.with_plugins(forward_model_step_classes=[FM1, FM2]).from_file(
tmp_path / "test.ert"
)
Expand Down
2 changes: 1 addition & 1 deletion tests/ert/unit_tests/config/test_gen_data_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def test_that_invalid_gendata_outfile_error_propagates(tmp_path):
)
with pytest.raises(
InvalidResponseFile,
match="Error reading GEN_DATA.*could not convert string.*4.910405046410615,4.910405046410615.*to float64",
match=r"Error reading GEN_DATA.*could not convert string.*4.910405046410615,4.910405046410615.*to float64",
):
config.read_from_file(tmp_path, 0, 0)

Expand Down
6 changes: 3 additions & 3 deletions tests/ert/unit_tests/config/test_gen_kw_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_gen_kw_config():
def test_gen_kw_config_duplicate_keys_raises():
with pytest.raises(
ConfigValidationError,
match="Duplicate GEN_KW keys 'KEY2' found, keys must be unique.",
match="Duplicate GEN_KW keys 'KEY2' found, keys must be unique\\.",
):
GenKwConfig(
name="KEY",
Expand Down Expand Up @@ -559,7 +559,7 @@ def test_gen_kw_config_validation():
)

with pytest.raises(
ConfigValidationError, match="config.ert.* No such template file"
ConfigValidationError, match=r"config.ert.* No such template file"
):
EnsembleConfig.from_dict(
config_dict={
Expand All @@ -575,7 +575,7 @@ def test_gen_kw_config_validation():
)

with pytest.raises(
ConfigValidationError, match="config.ert.* No such parameter file"
ConfigValidationError, match=r"config.ert.* No such parameter file"
):
EnsembleConfig.from_dict(
config_dict={
Expand Down
6 changes: 3 additions & 3 deletions tests/ert/unit_tests/config/test_parser_error_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ def test_that_unicode_decode_error_is_localized_first_line():

with pytest.raises(
ConfigValidationError,
match="Unsupported non UTF-8 character 'ÿ' found in file: .*test.ert",
match=r"Unsupported non UTF-8 character 'ÿ' found in file: .*test.ert",
) as caught_error:
ErtConfig.from_file("test.ert")

Expand Down Expand Up @@ -748,7 +748,7 @@ def test_that_unicode_decode_error_is_localized_random_line_single_insert():

with pytest.raises(
ConfigValidationError,
match="Unsupported non UTF-8 character " "'ÿ' found in file: .*test.ert",
match=r"Unsupported non UTF-8 character " "'ÿ' found in file: .*test.ert",
) as caught_error:
ErtConfig.from_file("test.ert")

Expand Down Expand Up @@ -809,7 +809,7 @@ def test_that_unicode_decode_error_is_localized_multiple_random_inserts(

with pytest.raises(
ConfigValidationError,
match="Unsupported non UTF-8 character 'ÿ' found in file: .*test.ert",
match=r"Unsupported non UTF-8 character 'ÿ' found in file: .*test.ert",
) as caught_error:
ErtConfig.from_file("test.ert")

Expand Down
2 changes: 1 addition & 1 deletion tests/ert/unit_tests/config/test_read_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ def test_unknown_date_unit_in_summary_files_raises_informative_errors(

with pytest.raises(
InvalidResponseFile,
match="Unknown date unit .* ANNUAL",
match=r"Unknown date unit .* ANNUAL",
):
read_summary(str(tmp_path / "test"), ["*"])

Expand Down
4 changes: 2 additions & 2 deletions tests/ert/unit_tests/config/test_surface_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def test_init_files_must_contain_placeholder_when_not_forward_init():
def test_when_base_surface_does_not_exist_gives_config_error():
with pytest.raises(
ConfigValidationError,
match="surface/small_out.irap not found",
match="surface/small_out\\.irap not found",
):
SurfaceConfig.from_config_list(
[
Expand Down Expand Up @@ -180,7 +180,7 @@ def test_config_file_line_sets_the_corresponding_properties(
def test_invalid_surface_files_gives_config_error():
Path("base_surface.irap").write_text("not valid irap", encoding="utf-8")
with pytest.raises(
ConfigValidationError, match="Could not load surface 'base_surface.irap'"
ConfigValidationError, match="Could not load surface 'base_surface\\.irap'"
):
_ = SurfaceConfig.from_config_list(
[
Expand Down
2 changes: 1 addition & 1 deletion tests/ert/unit_tests/field_utils/test_grdecl_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

def test_that_importing_mess_from_bgrdecl_raises_field_io_error(tmp_path):
resfo.write(tmp_path / "test.bgrdecl", [("FOPR ", resfo.MESS)])
with pytest.raises(ValueError, match="FOPR in .* has MESS type"):
with pytest.raises(ValueError, match=r"FOPR in .* has MESS type"):
import_bgrdecl(tmp_path / "test.bgrdecl", "FOPR ", (1, 1, 1))


Expand Down
2 changes: 1 addition & 1 deletion tests/ert/unit_tests/plugins/test_export_runpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def test_export_runpath_combination_parameter(writing_setup):

def test_export_runpath_bad_arguments(writing_setup):
writing_setup, config = writing_setup
with pytest.raises(ValueError, match="Expected |"):
with pytest.raises(ValueError, match="Expected \\|"):
writing_setup.export_job.run(config, ["wat"])


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def test_loading_of_eclipse_configurations(monkeypatch):
f.write("this:\n -should\n-be\ninvalid:yaml?")

monkeypatch.setenv("ECL100_SITE_CONFIG", "file.yml")
with pytest.raises(ValueError, match="Failed parse: file.yml as yaml"):
with pytest.raises(ValueError, match="Failed parse: file\\.yml as yaml"):
conf = ecl_config.Ecl100Config()

scalar_exe = "bin/scalar_exe"
Expand Down
6 changes: 3 additions & 3 deletions tests/ert/unit_tests/storage/test_local_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def test_that_saving_empty_responses_fails_nicely(tmp_path):

with pytest.raises(
ValueError,
match="Responses RESPONSE are empty. Cannot proceed with saving to storage.",
match="Responses RESPONSE are empty\\. Cannot proceed with saving to storage\\.",
):
ensemble.save_response("RESPONSE", empty_data, 0)

Expand Down Expand Up @@ -191,7 +191,7 @@ def test_that_saving_empty_parameters_fails_nicely(tmp_path):
)
with pytest.raises(
ValueError,
match="Parameters PARAMETER are empty. Cannot proceed with saving to storage.",
match="Parameters PARAMETER are empty\\. Cannot proceed with saving to storage\\.",
):
prior.save_parameters("PARAMETER", 0, empty_data)

Expand Down Expand Up @@ -359,7 +359,7 @@ def test_open_storage_with_corrupted_storage(tmp_path):
with open_storage(tmp_path / "storage", mode="w") as storage:
storage.create_experiment().create_ensemble(name="prior", ensemble_size=1)
os.remove(tmp_path / "storage" / "index.json")
with pytest.raises(ErtStorageException, match="No index.json"):
with pytest.raises(ErtStorageException, match="No index\\.json"):
open_storage(tmp_path / "storage", mode="w")


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ def test_gen_kw_forward_init(tmpdir, storage, load_forward_init):
ConfigValidationError,
match=(
"Loading GEN_KW from files created by "
"the forward model is not supported."
"the forward model is not supported\\."
),
):
create_runpath(storage, "config.ert")
Expand Down
2 changes: 1 addition & 1 deletion tests/ert/unit_tests/test_run_path_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def test_that_error_is_raised_when_data_file_is_badly_encoded(

with pytest.raises(
ValueError,
match="Unsupported non UTF-8 character found in file: .*MY_DATA_FILE.DATA",
match=r"Unsupported non UTF-8 character found in file: .*MY_DATA_FILE.DATA",
):
create_run_path(
run_args=run_args(ert_config, prior_ensemble),
Expand Down
2 changes: 1 addition & 1 deletion tests/ert/unit_tests/workflow_runner/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def test_that_failure_in_parsing_workflow_gives_config_validation_error():
with open("workflow", "w", encoding="utf-8") as f:
f.write("DEFINE\n")
with pytest.raises(
ConfigValidationError, match="DEFINE must have .* arguments"
ConfigValidationError, match=r"DEFINE must have .* arguments"
) as err:
_ = Workflow.from_file("workflow", None, {})
assert os.path.abspath(err.value.errors[0].filename) == os.path.abspath("workflow")
Expand Down
4 changes: 3 additions & 1 deletion tests/everest/test_config_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,9 @@ def test_that_missing_required_fields_cause_error():


def test_that_non_existing_workflow_jobs_cause_error():
with pytest.raises(ValidationError, match="No such file or directory (.*)jobs/JOB"):
with pytest.raises(
ValidationError, match=r"No such file or directory (.*)jobs/JOB"
):
EverestConfig.with_defaults(
install_workflow_jobs=[{"name": "job0", "source": "jobs/JOB"}],
workflows={
Expand Down
2 changes: 1 addition & 1 deletion tests/everest/test_controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def test_variable_name_index_validation(copy_test_data_to_tmp):
with pytest.raises(
ValidationError,
match="does not match any instance of "
"control_name.variable_name-variable_index",
"control_name\\.variable_name-variable_index",
):
EverestConfig.model_validate(config.model_dump(exclude_none=True))

Expand Down
2 changes: 1 addition & 1 deletion tests/everest/test_detached.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def test_server_status(copy_math_func_test_data_to_tmp):
def test_wait_for_server(server_is_running_mock, caplog, monkeypatch):
config = EverestConfig.with_defaults()

with pytest.raises(RuntimeError, match="Failed to start .* timeout"):
with pytest.raises(RuntimeError, match=r"Failed to start .* timeout"):
wait_for_server(config.output_dir, timeout=1)

assert not caplog.messages
Expand Down
2 changes: 1 addition & 1 deletion tests/everest/test_ropt_initialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def test_everest2ropt_cvar():
"number_of_realizations": 1,
}

with pytest.raises(ValidationError, match=".*Invalid CVaR section.*"):
with pytest.raises(ValidationError, match=r".*Invalid CVaR section.*"):
EverestConfig.model_validate(config_dict)

config_dict["optimization"]["cvar"] = {
Expand Down

0 comments on commit 3f8b320

Please sign in to comment.