diff --git a/pyproject.toml b/pyproject.toml index cfe295eabf8..3059aecab92 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -204,7 +204,6 @@ ignore = [ "PLR0912", # too-many-branches "PLR0911", # too-many-return-statements "PLC2701", # import-private-name - "PLR6201", # literal-membership "PLR0914", # too-many-locals "PLR6301", # no-self-use "PLW1641", # eq-without-hash diff --git a/src/ert/cli/main.py b/src/ert/cli/main.py index 10f325de1a3..6131dbe3b9c 100644 --- a/src/ert/cli/main.py +++ b/src/ert/cli/main.py @@ -54,22 +54,22 @@ def run_cli(args: Namespace, plugin_manager: ErtPluginManager | None = None) -> f"Config contains forward model step {fm_step_name} {count} time(s)", ) - if not ert_config.observations and args.mode not in [ + if not ert_config.observations and args.mode not in { ENSEMBLE_EXPERIMENT_MODE, TEST_RUN_MODE, WORKFLOW_MODE, - ]: + }: raise ErtCliError( f"To run {args.mode}, observations are needed. \n" f"Please add an observation file to {args.config}. Example: \n" f"'OBS_CONFIG observation_file.txt'." ) - if args.mode in [ + if args.mode in { ENSEMBLE_SMOOTHER_MODE, ES_MDA_MODE, ITERATIVE_ENSEMBLE_SMOOTHER_MODE, - ]: + }: if not ert_config.ensemble_config.parameter_configs: raise ErtCliError( f"To run {args.mode}, GEN_KW, FIELD or SURFACE parameters are needed. \n" diff --git a/src/ert/config/_read_summary.py b/src/ert/config/_read_summary.py index 6a444e0d9a4..396068007fc 100644 --- a/src/ert/config/_read_summary.py +++ b/src/ert/config/_read_summary.py @@ -268,7 +268,7 @@ def _read_spec( kw = entry.read_keyword() if kw in arrays: arrays[kw] = _check_vals(kw, spec, entry.read_array()) - if kw in ("WGNAMES ", "NAMES "): + if kw in {"WGNAMES ", "NAMES "}: wgnames = _check_vals(kw, spec, entry.read_array()) if kw == "DIMENS ": vals = _check_vals(kw, spec, entry.read_array()) diff --git a/src/ert/config/analysis_config.py b/src/ert/config/analysis_config.py index 3ba2024a35e..7f50ef77876 100644 --- a/src/ert/config/analysis_config.py +++ b/src/ert/config/analysis_config.py @@ -137,7 +137,7 @@ def from_dict(cls, config_dict: ConfigDict) -> AnalysisConfig: ) ) continue - if var_name in ["INVERSION", "IES_INVERSION"]: + if var_name in {"INVERSION", "IES_INVERSION"}: if value in inversion_str_map[module_name]: new_value = inversion_str_map[module_name][value] if var_name == "IES_INVERSION": diff --git a/src/ert/config/gen_kw_config.py b/src/ert/config/gen_kw_config.py index 47a20042874..65cd288c04d 100644 --- a/src/ert/config/gen_kw_config.py +++ b/src/ert/config/gen_kw_config.py @@ -219,7 +219,7 @@ def _check_non_negative_parameter(param: str, prior: PriorDict) -> None: if prior["function"] == "LOGNORMAL": _check_non_negative_parameter("MEAN", prior) _check_non_negative_parameter("STD", prior) - elif prior["function"] in ["NORMAL", "TRUNCATED_NORMAL"]: + elif prior["function"] in {"NORMAL", "TRUNCATED_NORMAL"}: _check_non_negative_parameter("STD", prior) if errors: raise ConfigValidationError.from_collected(errors) @@ -494,7 +494,7 @@ class TransformFunction: use_log: bool = False def __post_init__(self) -> None: - if self.transform_function_name in ["LOGNORMAL", "LOGUNIF"]: + if self.transform_function_name in {"LOGNORMAL", "LOGUNIF"}: self.use_log = True @staticmethod diff --git a/src/ert/config/parsing/config_schema_deprecations.py b/src/ert/config/parsing/config_schema_deprecations.py index 9f2942ec3a2..a97cbe89075 100644 --- a/src/ert/config/parsing/config_schema_deprecations.py +++ b/src/ert/config/parsing/config_schema_deprecations.py @@ -63,7 +63,7 @@ "dimension set using ENKF_NCOMP keyword. " "This can be safely removed.", ), - check=lambda line: str(line[1]) in ["ENKF_FORCE_NCOMP"], + check=lambda line: str(line[1]) in {"ENKF_FORCE_NCOMP"}, ), DeprecationInfo( keyword="RUNPATH", diff --git a/src/ert/config/parsing/observations_parser.py b/src/ert/config/parsing/observations_parser.py index b06c505b63e..ee7388fd318 100644 --- a/src/ert/config/parsing/observations_parser.py +++ b/src/ert/config/parsing/observations_parser.py @@ -325,9 +325,9 @@ def _validate_summary_values( for key, value in inp.items(): if key == "RESTART": date_dict.restart = validate_positive_int(value, key) - elif key in ["ERROR", "ERROR_MIN"]: + elif key in {"ERROR", "ERROR_MIN"}: float_values[str(key)] = validate_positive_float(value, key) - elif key in ["DAYS", "HOURS"]: + elif key in {"DAYS", "HOURS"}: setattr(date_dict, str(key).lower(), validate_positive_float(value, key)) elif key == "VALUE": float_values[str(key)] = validate_float(value, key) @@ -405,11 +405,11 @@ def _validate_gen_obs_values( output.restart = validate_positive_int(value, key) elif key == "VALUE": output.value = validate_float(value, key) - elif key in ["ERROR", "DAYS", "HOURS"]: + elif key in {"ERROR", "DAYS", "HOURS"}: setattr(output, str(key).lower(), validate_positive_float(value, key)) - elif key in ["DATE", "INDEX_LIST"]: + elif key in {"DATE", "INDEX_LIST"}: setattr(output, str(key).lower(), value) - elif key in ["OBS_FILE", "INDEX_FILE"]: + elif key in {"OBS_FILE", "INDEX_FILE"}: filename = value if not os.path.isabs(filename): filename = os.path.join(directory, filename) diff --git a/src/ert/config/queue_config.py b/src/ert/config/queue_config.py index 97275319936..4809f08056b 100644 --- a/src/ert/config/queue_config.py +++ b/src/ert/config/queue_config.py @@ -253,7 +253,7 @@ def _group_queue_options_by_queue_system( grouped[system] = { option_line[1]: option_line[2] for option_line in queue_config_list - if option_line[0] in (QueueSystemWithGeneric.GENERIC, system) + if option_line[0] in {QueueSystemWithGeneric.GENERIC, system} # Empty option values are ignored, yields defaults: and len(option_line) > 2 } @@ -317,7 +317,7 @@ def from_dict(cls, config_dict: ConfigDict) -> QueueConfig: tags = { fm_name.lower() for fm_name, *_ in config_dict.get(ConfigKeys.FORWARD_MODEL, []) - if fm_name in ["RMS", "FLOW", "ECLIPSE100", "ECLIPSE300"] + if fm_name in {"RMS", "FLOW", "ECLIPSE100", "ECLIPSE300"} } if tags: queue_options.project_code = "+".join(tags) diff --git a/src/ert/ensemble_evaluator/_ensemble.py b/src/ert/ensemble_evaluator/_ensemble.py index da9af3aec73..b09a0a81536 100644 --- a/src/ert/ensemble_evaluator/_ensemble.py +++ b/src/ert/ensemble_evaluator/_ensemble.py @@ -69,10 +69,10 @@ def _handle_started(self) -> None: self._state = ENSEMBLE_STATE_STARTED def _handle_failed(self) -> None: - if self._state not in [ + if self._state not in { ENSEMBLE_STATE_UNKNOWN, ENSEMBLE_STATE_STARTED, - ]: + }: logger.warning(self._msg, self._state, ENSEMBLE_STATE_FAILED) self._state = ENSEMBLE_STATE_FAILED diff --git a/src/ert/ensemble_evaluator/evaluator.py b/src/ert/ensemble_evaluator/evaluator.py index 2e43ad030df..7078ce412e4 100644 --- a/src/ert/ensemble_evaluator/evaluator.py +++ b/src/ert/ensemble_evaluator/evaluator.py @@ -186,10 +186,10 @@ async def _cancelled_handler(self, events: Sequence[EnsembleCancelled]) -> None: self.stop() async def _failed_handler(self, events: Sequence[EnsembleFailed]) -> None: - if self.ensemble.status in ( + if self.ensemble.status in { ENSEMBLE_STATE_STOPPED, ENSEMBLE_STATE_CANCELLED, - ): + }: return # if list is empty this call is not triggered by an # event, but as a consequence of some bad state @@ -263,7 +263,7 @@ async def handle_dispatch(self, websocket: ServerConnection) -> None: ) return - if type(event) in [EnsembleSucceeded, EnsembleFailed]: + if type(event) in {EnsembleSucceeded, EnsembleFailed}: return except ConnectionClosedError as connection_error: # Dispatchers may close the connection abruptly in the case of diff --git a/src/ert/gui/model/fm_step_list.py b/src/ert/gui/model/fm_step_list.py index 685d7684642..a60c6c9f4ed 100644 --- a/src/ert/gui/model/fm_step_list.py +++ b/src/ert/gui/model/fm_step_list.py @@ -86,9 +86,9 @@ def headerData( if role == Qt.ItemDataRole.DisplayRole: if orientation == Qt.Orientation.Horizontal: header = FM_STEP_COLUMNS[section] - if header in [ids.STDOUT, ids.STDERR]: + if header in {ids.STDOUT, ids.STDERR}: return header.upper() - elif header in [ids.MAX_MEMORY_USAGE]: + elif header in {ids.MAX_MEMORY_USAGE}: header = header.replace("_", " ") return header.capitalize() if orientation == Qt.Orientation.Vertical: diff --git a/src/ert/gui/model/snapshot.py b/src/ert/gui/model/snapshot.py index 7fd96ddceb1..6521d24d101 100644 --- a/src/ert/gui/model/snapshot.py +++ b/src/ert/gui/model/snapshot.py @@ -336,11 +336,11 @@ def data(self, index: QModelIndex, role: int = Qt.ItemDataRole.DisplayRole) -> A if index.column() == 1: return f"{node.data.status}" - if role in ( + if role in { Qt.ItemDataRole.StatusTipRole, Qt.ItemDataRole.WhatsThisRole, Qt.ItemDataRole.ToolTipRole, - ): + }: return "" if role == Qt.ItemDataRole.SizeHintRole: @@ -349,11 +349,11 @@ def data(self, index: QModelIndex, role: int = Qt.ItemDataRole.DisplayRole) -> A if role == Qt.ItemDataRole.FontRole: return QFont() - if role in ( + if role in { Qt.ItemDataRole.BackgroundRole, Qt.ItemDataRole.ForegroundRole, Qt.ItemDataRole.DecorationRole, - ): + }: return QColor() return QVariant() @@ -395,7 +395,7 @@ def _fm_step_data( if role == Qt.ItemDataRole.FontRole: data_name = FM_STEP_COLUMNS[index.column()] - if data_name in [ids.STDOUT, ids.STDERR] and file_has_content( + if data_name in {ids.STDOUT, ids.STDERR} and file_has_content( index.data(FileRole) ): font = QFont() @@ -404,7 +404,7 @@ def _fm_step_data( if role == Qt.ItemDataRole.ForegroundRole: data_name = FM_STEP_COLUMNS[index.column()] - if data_name in [ids.STDOUT, ids.STDERR] and file_has_content( + if data_name in {ids.STDOUT, ids.STDERR} and file_has_content( index.data(FileRole) ): return QColor(Qt.GlobalColor.blue) @@ -418,18 +418,18 @@ def _fm_step_data( if role == Qt.ItemDataRole.DisplayRole: data_name = FM_STEP_COLUMNS[index.column()] - if data_name in [ids.MAX_MEMORY_USAGE]: + if data_name in {ids.MAX_MEMORY_USAGE}: data = node.data bytes_: str | None = data.get(data_name) # type: ignore if bytes_: return byte_with_unit(float(bytes_)) - if data_name in [ids.STDOUT, ids.STDERR]: + if data_name in {ids.STDOUT, ids.STDERR}: if not file_has_content(index.data(FileRole)): return "-" return "View" if data_name in node.data else QVariant() - if data_name in [DURATION]: + if data_name in {DURATION}: start_time = node.data.get(ids.START_TIME) if start_time is None: return QVariant() @@ -444,7 +444,7 @@ def _fm_step_data( if role == FileRole: data_name = FM_STEP_COLUMNS[index.column()] - if data_name in [ids.STDOUT, ids.STDERR]: + if data_name in {ids.STDOUT, ids.STDERR}: return node.data.get(data_name, QVariant()) if role == RealIens: diff --git a/src/ert/gui/simulation/run_dialog.py b/src/ert/gui/simulation/run_dialog.py index 82e76aa0295..270b9034b74 100644 --- a/src/ert/gui/simulation/run_dialog.py +++ b/src/ert/gui/simulation/run_dialog.py @@ -154,7 +154,7 @@ def mouseMoveEvent(self, event: QMouseEvent | None) -> None: index = self.indexAt(event.pos()) if index.isValid(): data_name = FM_STEP_COLUMNS[index.column()] - if data_name in [ids.STDOUT, ids.STDERR] and file_has_content( + if data_name in {ids.STDOUT, ids.STDERR} and file_has_content( index.data(FileRole) ): self.setCursor(Qt.CursorShape.PointingHandCursor) diff --git a/src/ert/gui/tools/plot/plot_window.py b/src/ert/gui/tools/plot/plot_window.py index b3b8532e4c6..469fd503d7a 100644 --- a/src/ert/gui/tools/plot/plot_window.py +++ b/src/ert/gui/tools/plot/plot_window.py @@ -267,10 +267,10 @@ def _updateCustomizer( x_axis_type = PlotContext.UNKNOWN_AXIS y_axis_type = PlotContext.UNKNOWN_AXIS - if plot_widget.name in [ENSEMBLE, STATISTICS]: + if plot_widget.name in {ENSEMBLE, STATISTICS}: x_axis_type = preferred_x_axis_format y_axis_type = PlotContext.VALUE_AXIS - elif plot_widget.name in [DISTRIBUTION, CROSS_ENSEMBLE_STATISTICS]: + elif plot_widget.name in {DISTRIBUTION, CROSS_ENSEMBLE_STATISTICS}: y_axis_type = PlotContext.VALUE_AXIS elif plot_widget.name == HISTOGRAM: x_axis_type = PlotContext.VALUE_AXIS diff --git a/src/ert/plugins/__init__.py b/src/ert/plugins/__init__.py index 2b95bce0b99..ea548ca5402 100644 --- a/src/ert/plugins/__init__.py +++ b/src/ert/plugins/__init__.py @@ -20,7 +20,7 @@ def inner(*args: P.args, **kwargs: P.kwargs) -> Any: res = func(*args, **kwargs) if ( func.__name__ - in [ + in { "installable_jobs", "job_documentation", "installable_workflow_jobs", @@ -30,10 +30,9 @@ def inner(*args: P.args, **kwargs: P.kwargs) -> Any: "ecl100_config_path", "ecl300_config_path", "flow_config_path", - "help_links", "site_config_lines", "activate_script", - ] + } and res is not None ): return PluginResponse( diff --git a/src/ert/resources/forward_models/res/script/ecl_config.py b/src/ert/resources/forward_models/res/script/ecl_config.py index b0bbeb9196c..a3b0ed9fb62 100644 --- a/src/ert/resources/forward_models/res/script/ecl_config.py +++ b/src/ert/resources/forward_models/res/script/ecl_config.py @@ -96,7 +96,7 @@ def __contains__(self, version: str) -> bool: if version in self._config[Keys.versions]: return True - return self.default_version is not None and version in [None, Keys.default] + return self.default_version is not None and version in {None, Keys.default} def get_eclrun_env(self) -> dict[str, str] | None: if "eclrun_env" in self._config: @@ -108,7 +108,7 @@ def default_version(self) -> str | None: return self._config.get(Keys.default_version) def _get_version(self, version_arg: str | None) -> str: - if version_arg in [None, Keys.default]: + if version_arg in {None, Keys.default}: version = self.default_version else: version = version_arg diff --git a/src/ert/resources/forward_models/res/script/ecl_run.py b/src/ert/resources/forward_models/res/script/ecl_run.py index 561b920a165..306af292cac 100644 --- a/src/ert/resources/forward_models/res/script/ecl_run.py +++ b/src/ert/resources/forward_models/res/script/ecl_run.py @@ -161,10 +161,10 @@ def _is_unsmry(base: str, path: str) -> bool: if "." not in path: return False splitted = path.split(".") - return splitted[-2].endswith(base) and splitted[-1].lower() in [ + return splitted[-2].endswith(base) and splitted[-1].lower() in { "unsmry", "funsmry", - ] + } base = basepath.name candidates: list[str] = list( @@ -268,7 +268,7 @@ def __init__( # Dechipher the ecl_case argument. input_arg = ecl_case (_, ext) = os.path.splitext(input_arg) - if ext and ext in [".data", ".DATA"]: + if ext and ext in {".data", ".DATA"}: data_file = input_arg elif input_arg.islower(): data_file = input_arg + ".data" diff --git a/src/ert/run_models/base_run_model.py b/src/ert/run_models/base_run_model.py index a426c5be7a1..808eae059d7 100644 --- a/src/ert/run_models/base_run_model.py +++ b/src/ert/run_models/base_run_model.py @@ -436,10 +436,10 @@ def _current_progress(self) -> tuple[float, int]: if all_realizations: for real in all_realizations.values(): - if real["status"] in [ + if real["status"] in { REALIZATION_STATE_FINISHED, REALIZATION_STATE_FAILED, - ]: + }: done_realizations += 1 realization_progress = float(done_realizations) / len( @@ -505,10 +505,10 @@ async def run_monitor( async with Monitor(ee_config.get_connection_info()) as monitor: logger.debug("connected") async for event in monitor.track(heartbeat_interval=0.1): - if type(event) in ( + if type(event) in { EESnapshot, EESnapshotUpdate, - ): + }: event = cast(EESnapshot | EESnapshotUpdate, event) await asyncio.get_running_loop().run_in_executor( None, @@ -517,10 +517,10 @@ async def run_monitor( iteration, ) - if event.snapshot.get(STATUS) in [ + if event.snapshot.get(STATUS) in { ENSEMBLE_STATE_STOPPED, ENSEMBLE_STATE_FAILED, - ]: + }: logger.debug( "observed evaluation stopped event, signal done" ) diff --git a/src/ert/run_models/everest_run_model.py b/src/ert/run_models/everest_run_model.py index aa28a26ef55..03223c4c5d2 100644 --- a/src/ert/run_models/everest_run_model.py +++ b/src/ert/run_models/everest_run_model.py @@ -699,7 +699,7 @@ def _slug(entity: str) -> str: def send_snapshot_event(self, event: Event, iteration: int) -> None: super().send_snapshot_event(event, iteration) - if type(event) in (EESnapshot, EESnapshotUpdate): + if type(event) in {EESnapshot, EESnapshotUpdate}: newstatus = self._simulation_status(self.get_current_snapshot()) if self.status != newstatus: # No change in status self._sim_callback(newstatus) diff --git a/src/ert/shared/net_utils.py b/src/ert/shared/net_utils.py index fbcb80cebf7..cbd321a79f1 100644 --- a/src/ert/shared/net_utils.py +++ b/src/ert/shared/net_utils.py @@ -123,7 +123,7 @@ def _bind_socket( f"error msg is: {err_info.strerror}" ) from err_info except OSError as err_info: - if err_info.errno in (48, 98): + if err_info.errno in {48, 98}: raise PortAlreadyInUseException( f"Port {port} already in use." ) from err_info diff --git a/src/everest/bin/utils.py b/src/everest/bin/utils.py index 440f7398e43..19971b9adfe 100644 --- a/src/everest/bin/utils.py +++ b/src/everest/bin/utils.py @@ -260,7 +260,7 @@ def _get_jobs_status(progress): job_progress[job_idx] = JobProgress(name=job["name"]) realization = int(job["realization"]) status = job["status"] - if status in [JOB_RUNNING, JOB_SUCCESS, JOB_FAILURE]: + if status in {JOB_RUNNING, JOB_SUCCESS, JOB_FAILURE}: job_progress[job_idx].status[status].append(realization) return job_progress.values() diff --git a/src/everest/config/install_data_config.py b/src/everest/config/install_data_config.py index be8773004fd..23948574355 100644 --- a/src/everest/config/install_data_config.py +++ b/src/everest/config/install_data_config.py @@ -34,6 +34,6 @@ def validate_link_type(cls, link): # pylint: disable=E0213 @model_validator(mode="after") def validate_target(self): - if self.target in (".", "./"): + if self.target in {".", "./"}: self.target = Path(self.source).name return self diff --git a/src/everest/config/validation_utils.py b/src/everest/config/validation_utils.py index 05c150b70e6..3359bf20600 100644 --- a/src/everest/config/validation_utils.py +++ b/src/everest/config/validation_utils.py @@ -158,7 +158,7 @@ def check_path_valid(path: str): os.lstat(os.path.join(root, dirname)) except OSError as e: - if e.errno in (errno.ENAMETOOLONG, errno.ERANGE): + if e.errno in {errno.ENAMETOOLONG, errno.ERANGE}: raise ValueError(e.strerror) from e except TypeError as e: raise ValueError(str(e)) from e @@ -279,7 +279,7 @@ def _job_config_index(*args): ( i for i, arg in enumerate(args) - if arg in ["-c", "--config"] and i + 1 < len(args) + if arg in {"-c", "--config"} and i + 1 < len(args) ), None, ) @@ -299,7 +299,7 @@ def _job_config_index(*args): if (index := _job_config_index(*args)) is None: raise ValueError(f"No config file specified for job {job}") - if args[0] in ("run", "lint") and ( + if args[0] in {"run", "lint"} and ( errors := lint_forward_model_job(job, args[index : index + 2]) ): raise ValueError("\n\t".join(errors)) diff --git a/src/everest/optimizer/everest2ropt.py b/src/everest/optimizer/everest2ropt.py index 06015f8cfb5..b8aaafc4b60 100644 --- a/src/everest/optimizer/everest2ropt.py +++ b/src/everest/optimizer/everest2ropt.py @@ -138,7 +138,7 @@ def _variable_initial_guess_list_injection( variables["names"].extend(ropt_names) variables["initial_values"].extend(control.initial_values) for key, value in asdict(control).items(): - if key not in (*IGNORE_KEYS, "initial_values"): + if key not in {*IGNORE_KEYS, "initial_values"}: (gradients if "perturbation" in key else variables)[key].extend( [value] * guesses ) diff --git a/tests/ert/ui_tests/gui/conftest.py b/tests/ert/ui_tests/gui/conftest.py index 6590180b9d5..bfdddf77a97 100644 --- a/tests/ert/ui_tests/gui/conftest.py +++ b/tests/ert/ui_tests/gui/conftest.py @@ -255,10 +255,10 @@ def handle_dialog(): lambda: handle_run_path_dialog(gui, qtbot, delete_run_path=False), ) - if not experiment_mode.name() in ( + if not experiment_mode.name() in { "Ensemble experiment", "Evaluate ensemble", - ): + }: QTimer.singleShot(500, handle_dialog) qtbot.mouseClick(run_experiment, Qt.LeftButton) diff --git a/tests/ert/unit_tests/config/config_dict_generator.py b/tests/ert/unit_tests/config/config_dict_generator.py index 0527e57cfe3..9acedff897d 100644 --- a/tests/ert/unit_tests/config/config_dict_generator.py +++ b/tests/ert/unit_tests/config/config_dict_generator.py @@ -167,7 +167,7 @@ def valid_queue_values(option_name, queue_system): elif option_name in queue_options_by_type["posfloat"][queue_system]: return small_floats.map(str) elif option_name in queue_options_by_type["posint"][queue_system]: - if option_name in ["NUM_NODES", "NUM_CPUS_PER_NODE"]: + if option_name in {"NUM_NODES", "NUM_CPUS_PER_NODE"}: return st.just("1") return positives.map(str) elif option_name in queue_options_by_type["bool"][queue_system]: diff --git a/tests/ert/unit_tests/config/observations_generator.py b/tests/ert/unit_tests/config/observations_generator.py index 0e66c7a2fd3..6811c1537fd 100644 --- a/tests/ert/unit_tests/config/observations_generator.py +++ b/tests/ert/unit_tests/config/observations_generator.py @@ -205,7 +205,7 @@ def summary_observations( if time_type == "date": date = draw(dates) kws["date"] = date.strftime("%Y-%m-%d") - if time_type in ["days", "hours"]: + if time_type in {"days", "hours"}: kws[time_type] = draw(st.floats(min_value=1, max_value=3000)) if time_type == "restart": kws[time_type] = draw(st.integers(min_value=1, max_value=10)) diff --git a/tests/ert/unit_tests/config/test_create_forward_model_json.py b/tests/ert/unit_tests/config/test_create_forward_model_json.py index 31102b27927..2f5846038fc 100644 --- a/tests/ert/unit_tests/config/test_create_forward_model_json.py +++ b/tests/ert/unit_tests/config/test_create_forward_model_json.py @@ -263,7 +263,7 @@ def verify_json_dump(fm_steplist, config, selected_steps, run_id): step["name"] = default_name_if_none(step["name"]) for key in json_keywords: - if key in ["stdout", "stderr"]: + if key in {"stdout", "stderr"}: assert ( create_std_file(step, std=key, step_index=step_index) == loaded_step[key] diff --git a/tests/ert/unit_tests/config/test_ert_config.py b/tests/ert/unit_tests/config/test_ert_config.py index 2ed61d4f857..8d5181d7948 100644 --- a/tests/ert/unit_tests/config/test_ert_config.py +++ b/tests/ert/unit_tests/config/test_ert_config.py @@ -1659,7 +1659,7 @@ def test_no_timemap_or_refcase_provides_clear_error(): def test_that_multiple_errors_are_shown_when_validating_observation_config(): with fileinput.input("observations/observations.txt", inplace=True) as fin: for line_number, line in enumerate(fin, 1): - if line_number in [13, 32]: + if line_number in {13, 32}: continue print(line, end="") diff --git a/tests/ert/unit_tests/dark_storage/test_http_endpoints.py b/tests/ert/unit_tests/dark_storage/test_http_endpoints.py index 7c3d560340a..f453122df0f 100644 --- a/tests/ert/unit_tests/dark_storage/test_http_endpoints.py +++ b/tests/ert/unit_tests/dark_storage/test_http_endpoints.py @@ -30,7 +30,7 @@ def test_get_ensemble(poly_example_tmp_dir, dark_storage_client): ensemble_json = resp.json() assert ensemble_json["experiment_id"] == experiment_json[0]["id"] - assert ensemble_json["userdata"]["name"] in ("iter-0", "iter-1") + assert ensemble_json["userdata"]["name"] in {"iter-0", "iter-1"} assert ensemble_json["userdata"]["experiment_name"] == experiment_json[0]["name"] @@ -48,7 +48,7 @@ def test_get_experiment_ensemble(poly_example_tmp_dir, dark_storage_client): assert len(ensembles_json) == 2 assert ensembles_json[0]["experiment_id"] == experiment_json[0]["id"] - assert ensembles_json[0]["userdata"]["name"] in ("iter-0", "iter-1") + assert ensembles_json[0]["userdata"]["name"] in {"iter-0", "iter-1"} @pytest.mark.integration_test diff --git a/tests/ert/unit_tests/ensemble_evaluator/test_ensemble_evaluator.py b/tests/ert/unit_tests/ensemble_evaluator/test_ensemble_evaluator.py index f2a645f6d9d..2d2cad74f3b 100644 --- a/tests/ert/unit_tests/ensemble_evaluator/test_ensemble_evaluator.py +++ b/tests/ert/unit_tests/ensemble_evaluator/test_ensemble_evaluator.py @@ -524,7 +524,7 @@ async def test_ensure_multi_level_events_in_order(evaluator_to_use): assert snapshot_event_received == True final_event_was_EETerminated = True assert ensemble_state == ENSEMBLE_STATE_STOPPED - if type(event) in [EESnapshot, EESnapshotUpdate]: + if type(event) in {EESnapshot, EESnapshotUpdate}: # if we get an snapshot event than this need to be valid assert final_event_was_EETerminated == False snapshot_event_received = True diff --git a/tests/ert/unit_tests/ensemble_evaluator/test_ensemble_legacy.py b/tests/ert/unit_tests/ensemble_evaluator/test_ensemble_legacy.py index 5b845a6e3d8..a657a872571 100644 --- a/tests/ert/unit_tests/ensemble_evaluator/test_ensemble_legacy.py +++ b/tests/ert/unit_tests/ensemble_evaluator/test_ensemble_legacy.py @@ -51,13 +51,13 @@ async def test_run_legacy_ensemble( Monitor(config) as monitor, ): async for event in monitor.track(): - if type(event) in ( + if type(event) in { EESnapshotUpdate, EESnapshot, - ) and event.snapshot.get(identifiers.STATUS) in [ + } and event.snapshot.get(identifiers.STATUS) in { state.ENSEMBLE_STATE_FAILED, state.ENSEMBLE_STATE_STOPPED, - ]: + }: await monitor.signal_done() assert evaluator._ensemble.status == state.ENSEMBLE_STATE_STOPPED assert len(evaluator._ensemble.get_successful_realizations()) == num_reals diff --git a/tests/ert/unit_tests/ensemble_evaluator/test_scheduler.py b/tests/ert/unit_tests/ensemble_evaluator/test_scheduler.py index 0b981b1cbce..0160f2053d9 100644 --- a/tests/ert/unit_tests/ensemble_evaluator/test_scheduler.py +++ b/tests/ert/unit_tests/ensemble_evaluator/test_scheduler.py @@ -34,13 +34,13 @@ async def _run_monitor(): await asyncio.wait_for(rename_and_wait(), timeout=5) except TimeoutError: await monitor.signal_done() - if type(event) in ( + if type(event) in { EESnapshot, EESnapshotUpdate, - ) and event.snapshot.get(identifiers.STATUS) in [ + } and event.snapshot.get(identifiers.STATUS) in { state.ENSEMBLE_STATE_FAILED, state.ENSEMBLE_STATE_STOPPED, - ]: + }: await monitor.signal_done() return True diff --git a/tests/ert/unit_tests/gui/tools/plot/test_plot_api.py b/tests/ert/unit_tests/gui/tools/plot/test_plot_api.py index 1a1bdc0c436..91794aa6260 100644 --- a/tests/ert/unit_tests/gui/tools/plot/test_plot_api.py +++ b/tests/ert/unit_tests/gui/tools/plot/test_plot_api.py @@ -143,7 +143,7 @@ def test_load_history_data_searches_until_history_found(api): ensemble_ids = [ ens.id for ens in api.get_all_ensembles() - if ens.name in ["no-history", "default_0"] + if ens.name in {"no-history", "default_0"} ] df = api.history_data(ensemble_ids=ensemble_ids, key="FOPR") assert_frame_equal( @@ -155,7 +155,7 @@ def test_load_history_data_returns_empty_frame_if_no_history(api): ensemble_ids = [ ens.id for ens in api.get_all_ensembles() - if ens.name in ["no-history", "still-no-history"] + if ens.name in {"no-history", "still-no-history"} ] df = api.history_data(ensemble_ids=ensemble_ids, key="FOPR") assert_frame_equal(df, pd.DataFrame()) diff --git a/tests/ert/unit_tests/scheduler/bin/squeue.py b/tests/ert/unit_tests/scheduler/bin/squeue.py index 8b09369cf37..b4be01ab0b1 100644 --- a/tests/ert/unit_tests/scheduler/bin/squeue.py +++ b/tests/ert/unit_tests/scheduler/bin/squeue.py @@ -56,7 +56,7 @@ def main() -> None: if returncode != "0": state = "FAILED" - if state in ["PENDING", "RUNNING"]: + if state in {"PENDING", "RUNNING"}: print(f"{job} {state}") diff --git a/tests/ert/unit_tests/scheduler/test_lsf_driver.py b/tests/ert/unit_tests/scheduler/test_lsf_driver.py index 369356b2f9f..b98e914ae54 100644 --- a/tests/ert/unit_tests/scheduler/test_lsf_driver.py +++ b/tests/ert/unit_tests/scheduler/test_lsf_driver.py @@ -1334,7 +1334,7 @@ async def finished(iens: int, returncode: int): # get SIGTERM but rather LSF_FAILED_JOB. Whether SIGNAL_OFFSET is # added or not depends on various shell configurations and is a # detail we do not want to track. - assert returncode in (SIGTERM, SIGNAL_OFFSET + SIGTERM, LSF_FAILED_JOB) + assert returncode in {SIGTERM, SIGNAL_OFFSET + SIGTERM, LSF_FAILED_JOB} await poll(driver, {0}, finished=finished) assert "ERROR" not in str(caplog.text) diff --git a/tests/ert/unit_tests/scheduler/test_openpbs_driver.py b/tests/ert/unit_tests/scheduler/test_openpbs_driver.py index f8745f54f6d..e3a35e3a3c3 100644 --- a/tests/ert/unit_tests/scheduler/test_openpbs_driver.py +++ b/tests/ert/unit_tests/scheduler/test_openpbs_driver.py @@ -72,7 +72,7 @@ async def mocked_submit(self, iens, *_args, **_kwargs): jobstate = _parse_jobs_dict({"1": {"job_state": statestr, "Exit_status": 0}})[ "1" ] - if statestr in ["E", "F"] and "1" in driver._non_finished_job_ids: + if statestr in {"E", "F"} and "1" in driver._non_finished_job_ids: driver._non_finished_job_ids.remove("1") driver._finished_job_ids.add("1") await driver._process_job_update("1", jobstate) diff --git a/tests/everest/test_controls.py b/tests/everest/test_controls.py index e01e1050adf..2c6c8be61ab 100644 --- a/tests/everest/test_controls.py +++ b/tests/everest/test_controls.py @@ -186,7 +186,7 @@ def test_individual_control_variable_config(copy_test_data_to_tmp): exp_var_def = _perturb_control_zero(config, gmin, gmax, ginit, fill) # Not complete configuration - if None in [gmin, gmax, ginit] and not fill: + if None in {gmin, gmax, ginit} and not fill: with pytest.raises(expected_exception=ValidationError): EverestConfig.model_validate(config.to_dict()) continue diff --git a/tests/everest/test_detached.py b/tests/everest/test_detached.py index 0e9c9008344..258d98628da 100644 --- a/tests/everest/test_detached.py +++ b/tests/everest/test_detached.py @@ -91,10 +91,7 @@ async def test_https_requests(copy_math_func_test_data_to_tmp): server_status = everserver_status(status_path) # Possible the case completed while waiting for the server to stop - assert server_status["status"] in [ - ServerStatus.stopped, - ServerStatus.completed, - ] + assert server_status["status"] in {ServerStatus.stopped, ServerStatus.completed} assert not server_is_running(*server_context) else: server_status = everserver_status(status_path)