From d7c4cec4c2980a70176b59be40a18ed53981aa15 Mon Sep 17 00:00:00 2001 From: haosenwang1018 <167664334+haosenwang1018@users.noreply.github.com> Date: Thu, 26 Feb 2026 03:50:04 +0000 Subject: [PATCH] fix: replace 9 bare except clauses with except Exception --- taiga/base/api/request.py | 2 +- taiga/base/api/utils/encoders.py | 2 +- taiga/base/filters.py | 6 +++--- taiga/importers/github/importer.py | 2 +- taiga/importers/trello/importer.py | 2 +- taiga/projects/filters.py | 2 +- taiga/projects/references/api.py | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/taiga/base/api/request.py b/taiga/base/api/request.py index 712ab5754..f42b3c284 100644 --- a/taiga/base/api/request.py +++ b/taiga/base/api/request.py @@ -391,7 +391,7 @@ def _parse(self): try: parsed = parser.parse(stream, media_type, self.parser_context) - except: + except Exception: # If we get an exception during parsing, fill in empty data and # re-raise. Ensures we don't simply repeat the error when # attempting to render the browsable renderer response, or when diff --git a/taiga/base/api/utils/encoders.py b/taiga/base/api/utils/encoders.py index 700fc7f8b..d554944ce 100644 --- a/taiga/base/api/utils/encoders.py +++ b/taiga/base/api/utils/encoders.py @@ -85,7 +85,7 @@ def default(self, o): elif hasattr(o, "__getitem__"): try: return dict(o) - except: + except Exception: pass elif hasattr(o, "__iter__"): return [i for i in o] diff --git a/taiga/base/filters.py b/taiga/base/filters.py index 6b65da4b1..c02375f06 100644 --- a/taiga/base/filters.py +++ b/taiga/base/filters.py @@ -143,7 +143,7 @@ def filter_queryset(self, request, queryset, view): "project" in request.QUERY_PARAMS): try: project_id = int(request.QUERY_PARAMS["project"]) - except: + except Exception: logger.error("Filtering project diferent value than an integer: {}".format( request.QUERY_PARAMS["project"] )) @@ -268,7 +268,7 @@ def filter_queryset(self, request, queryset, view): if "project" in request.QUERY_PARAMS: try: project_id = int(request.QUERY_PARAMS["project"]) - except: + except Exception: logger.error("Filtering project diferent value than an integer: {}".format( request.QUERY_PARAMS["project"])) raise exc.BadRequest(_("'project' must be an integer value.")) @@ -388,7 +388,7 @@ def _prepare_filter_data(self, query_param_value): def _transform_value(value): try: return int(value) - except: + except Exception: if value in self._special_values_dict: return self._special_values_dict[value] raise exc.BadRequest() diff --git a/taiga/importers/github/importer.py b/taiga/importers/github/importer.py index b6206d9c1..275d83491 100644 --- a/taiga/importers/github/importer.py +++ b/taiga/importers/github/importer.py @@ -540,7 +540,7 @@ def get_access_token(cls, client_id, client_secret, code): else: try: return dict(parse_qsl(result.content))[b'access_token'].decode('utf-8') - except: + except Exception: raise InvalidAuthResult() diff --git a/taiga/importers/trello/importer.py b/taiga/importers/trello/importer.py index 43a2e41a5..814bb7c14 100644 --- a/taiga/importers/trello/importer.py +++ b/taiga/importers/trello/importer.py @@ -132,7 +132,7 @@ def list_users(self, project_id): avatar = 'https://www.gravatar.com/avatar/' + user['gravatarHash'] + '.jpg?s=50' elif user['avatarHash'] is not None: avatar = 'https://trello-members.s3.amazonaws.com/' + user['id'] + '/' + user['avatarHash'] + '/50.png' - except: + except Exception: # NOTE: Sometimes this piece of code return this exception: # # File "/home/taiga/taiga-back/taiga/importers/trello/importer.py" in list_users diff --git a/taiga/projects/filters.py b/taiga/projects/filters.py index 1ac47d790..56052ffe7 100644 --- a/taiga/projects/filters.py +++ b/taiga/projects/filters.py @@ -48,7 +48,7 @@ def filter_queryset(self, request, queryset, view): "project" in request.QUERY_PARAMS): try: project_id = int(request.QUERY_PARAMS["project"]) - except: + except Exception: logger.error("Filtering project diferent value than an integer: {}".format( request.QUERY_PARAMS["project"] )) diff --git a/taiga/projects/references/api.py b/taiga/projects/references/api.py index 4e1f977c5..b588cfb62 100644 --- a/taiga/projects/references/api.py +++ b/taiga/projects/references/api.py @@ -77,7 +77,7 @@ def list(self, request, **kwargs): issue = project.issues.filter(ref=value).first() if issue: result["issue"] = issue.pk - except: + except Exception: value = data["ref"] if user_has_perm(request.user, "view_wiki_pages", project):