From a3db88099e1cbd8df6bc842579f2c56a437f72f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Morais?= <146729917+SMoraisAnsys@users.noreply.github.com> Date: Tue, 30 Jul 2024 14:37:05 +0200 Subject: [PATCH] REFACTOR: Cleanup bandit warnings (#4962) Co-authored-by: Maxime Rey <87315832+MaxJPRey@users.noreply.github.com> --- pyaedt/modules/PostProcessor.py | 17 ++++++++++++----- pyaedt/workflows/project/create_report.py | 4 ++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/pyaedt/modules/PostProcessor.py b/pyaedt/modules/PostProcessor.py index 7408c88f9f3..7e1fbcd7e90 100644 --- a/pyaedt/modules/PostProcessor.py +++ b/pyaedt/modules/PostProcessor.py @@ -2453,7 +2453,9 @@ def _get_cs_plane_ids(self): name2refid[cs_id + 1] = name + ":YZ" name2refid[cs_id + 2] = name + ":XZ" except Exception: - pass + self.logger.debug( + "Something went wrong with key {} while retrieving coordinate systems plane ids.".format(ds) + ) # pragma: no cover return name2refid @pyaedt_function_handler() @@ -2507,7 +2509,9 @@ def _get_fields_plot(self): plots[plot_name].MaxArrowSpacing = arrow_setts["MaxArrowSpacing"] plots[plot_name].GridColor = surf_setts["GridColor"] except Exception: - pass + self.logger.debug( + "Something went wrong with setup {} while retrieving fields plot.".format(setup) + ) # pragma: no cover return plots # TODO: define a fields calculator module and make robust !! @@ -3245,7 +3249,7 @@ def _create_fieldplot( try: self._app.modeler.fit_all() except Exception: - pass + self.logger.debug("Something went wrong with `fit_all` while creating field plot.") # pragma: no cover self._desktop.TileWindows(0) self._app.desktop_class.active_design(self._oproject, self._app.design_name) @@ -3305,7 +3309,9 @@ def _create_fieldplot_line_traces( try: self._app._modeler.fit_all() except Exception: - pass + self.logger.debug( + "Something went wrong with `fit_all` while creating field plot with line traces." + ) # pragma: no cover self._desktop.TileWindows(0) self._app.desktop_class.active_design(self._oproject, self._app.design_name) @@ -4289,7 +4295,8 @@ def export_model_obj(self, assignment=None, export_path=None, export_as_single_o """ if assignment and not isinstance(assignment, (list, tuple)): assignment = [assignment] - assert self._app._aedt_version >= "2021.2", self.logger.error("Object is supported from AEDT 2021 R2.") + if self._app._aedt_version < "2021.2": + raise RuntimeError("Object is supported from AEDT 2021 R2.") # pragma: no cover if not export_path: export_path = self._app.working_directory if not assignment: diff --git a/pyaedt/workflows/project/create_report.py b/pyaedt/workflows/project/create_report.py index 1b4ce50ee9a..e8483b8df3a 100644 --- a/pyaedt/workflows/project/create_report.py +++ b/pyaedt/workflows/project/create_report.py @@ -79,8 +79,8 @@ def main(extension_args): out = report.save_pdf(aedtapp.working_directory, "AEDT_Results.pdf") aedtapp.logger.info(f"Report Generated. {out}") if is_windows and not extension_args["is_test"]: # pragma: no cover - try: # nosec - os.startfile(out) + try: + os.startfile(out) # nosec except Exception: # pragma: no cover aedtapp.logger.warning(f"Failed to open {out}")