From b66672e3e69f4d38eea4f83240914820e6d84c1b Mon Sep 17 00:00:00 2001 From: MoritzWeber Date: Tue, 31 Oct 2023 14:41:17 +0100 Subject: [PATCH] ci: Prohibit use of `print` function --- backend/capellacollab/config/diff.py | 2 ++ backend/capellacollab/projects/routes.py | 2 -- .../projects/toolmodels/modelsources/git/github/handler.py | 3 --- backend/capellacollab/sessions/operators/k8s.py | 6 ++++-- backend/capellacollab/settings/modelsources/git/askpass.py | 4 +++- backend/pyproject.toml | 4 ++++ 6 files changed, 13 insertions(+), 8 deletions(-) diff --git a/backend/capellacollab/config/diff.py b/backend/capellacollab/config/diff.py index ddb12c63f..4081e72a0 100644 --- a/backend/capellacollab/config/diff.py +++ b/backend/capellacollab/config/diff.py @@ -1,6 +1,8 @@ # SPDX-FileCopyrightText: Copyright DB Netz AG and the capella-collab-manager contributors # SPDX-License-Identifier: Apache-2.0 +# pylint: disable=bad-builtin + import pathlib import deepdiff diff --git a/backend/capellacollab/projects/routes.py b/backend/capellacollab/projects/routes.py index 3a80e0bd1..e46a16d8f 100644 --- a/backend/capellacollab/projects/routes.py +++ b/backend/capellacollab/projects/routes.py @@ -205,8 +205,6 @@ def _delete_all_pipelines_for_project( pipelines: list[backups_models.DatabaseBackup] = [] for model in project.models: pipelines.extend(backups_crud.get_pipelines_for_tool_model(db, model)) - print(project.models) - print(pipelines) for pipeline in pipelines: backups_core.delete_pipeline(db, pipeline, username, True) diff --git a/backend/capellacollab/projects/toolmodels/modelsources/git/github/handler.py b/backend/capellacollab/projects/toolmodels/modelsources/git/github/handler.py index 77fce82fd..e5a1d5552 100644 --- a/backend/capellacollab/projects/toolmodels/modelsources/git/github/handler.py +++ b/backend/capellacollab/projects/toolmodels/modelsources/git/github/handler.py @@ -109,9 +109,6 @@ def get_last_pipeline_runs( headers = None if self.git_model.password: headers = self.__get_headers(self.git_model.password) - print( - f"{self.git_instance.api_url}/repos/{project_id}/actions/runs?branch={parse.quote(self.git_model.revision, safe='')}&per_page=20" - ) response = requests.get( f"{self.git_instance.api_url}/repos/{project_id}/actions/runs?branch={parse.quote(self.git_model.revision, safe='')}&per_page=20", headers=headers, diff --git a/backend/capellacollab/sessions/operators/k8s.py b/backend/capellacollab/sessions/operators/k8s.py index 5fe8e51ef..90d6b4f7c 100644 --- a/backend/capellacollab/sessions/operators/k8s.py +++ b/backend/capellacollab/sessions/operators/k8s.py @@ -976,7 +976,9 @@ def print_file_tree_as_json(): import pathlib import sys - print("Using CLI arguments: " + str(sys.argv[1:]), file=sys.stderr) + print( # pylint: disable=bad-builtin + "Using CLI arguments: " + str(sys.argv[1:]), file=sys.stderr + ) def get_files(dir: pathlib.Path, show_hidden: bool): file = { @@ -1004,7 +1006,7 @@ def get_files(dir: pathlib.Path, show_hidden: bool): return file - print( + print( # pylint: disable=bad-builtin json.dumps( get_files( pathlib.Path(sys.argv[1]), json.loads(sys.argv[2]) diff --git a/backend/capellacollab/settings/modelsources/git/askpass.py b/backend/capellacollab/settings/modelsources/git/askpass.py index eaecd795c..27798f0da 100755 --- a/backend/capellacollab/settings/modelsources/git/askpass.py +++ b/backend/capellacollab/settings/modelsources/git/askpass.py @@ -7,5 +7,7 @@ import sys if __name__ == "__main__": - print(os.environ["GIT_" + sys.argv[1].split()[0].upper()]) + print( # pylint: disable=bad-builtin + os.environ["GIT_" + sys.argv[1].split()[0].upper()] + ) raise SystemExit(0) diff --git a/backend/pyproject.toml b/backend/pyproject.toml index c4a1feb0d..becb65a00 100644 --- a/backend/pyproject.toml +++ b/backend/pyproject.toml @@ -150,6 +150,9 @@ add-ignore = [ "D213", # Multi-line docstring summary should start at the second line ] +[tool.pylint] +bad-functions = ["print"] + [tool.pylint.messages_control] disable = [ "broad-except", @@ -220,6 +223,7 @@ extension-pkg-whitelist = "pydantic" # https://github.com/pydantic/pydantic/issu [tool.pylint.master] init-import = "yes" +load-plugins = "pylint.extensions.bad_builtin" [tool.pylint.similarities] min-similarity-lines = 6