From 053de2b14ed9c8d4ab86f3cb147502ebbe050a65 Mon Sep 17 00:00:00 2001 From: ranzhigg Date: Tue, 8 Sep 2026 20:46:43 +0800 Subject: [PATCH] fix: restore Python 3 exception syntax --- app/api/endpoints/media.py | 2 +- app/application/plugin/data.py | 2 +- app/domain/classification/facts.py | 2 +- app/modules/musicbrainz/__init__.py | 2 +- app/modules/themoviedb/__init__.py | 2 +- app/runtime/extensions/module/contracts.py | 2 +- app/startup/composition/enrichment.py | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/api/endpoints/media.py b/app/api/endpoints/media.py index 641bab50f..f5da8d053 100644 --- a/app/api/endpoints/media.py +++ b/app/api/endpoints/media.py @@ -116,7 +116,7 @@ def _is_valid_source_media_id( try: UUID(normalized_media_id) return True - except TypeError, ValueError: + except (TypeError, ValueError): return False if normalized_source == MediaSource.DoubanMusic and ":" in normalized_media_id: album_id, track_number = normalized_media_id.split(":", 1) diff --git a/app/application/plugin/data.py b/app/application/plugin/data.py index 651349e7f..557813a41 100644 --- a/app/application/plugin/data.py +++ b/app/application/plugin/data.py @@ -169,7 +169,7 @@ def plugin_data_serialized_chars(value: JsonData) -> Optional[int]: """计算合法 JSON 值的紧凑字符数,异常对象不执行自定义字符串化。""" try: return len(json.dumps(value, ensure_ascii=False, separators=(",", ":"))) - except TypeError, ValueError: + except (TypeError, ValueError): return None diff --git a/app/domain/classification/facts.py b/app/domain/classification/facts.py index 8301829af..bbd2ca4f6 100644 --- a/app/domain/classification/facts.py +++ b/app/domain/classification/facts.py @@ -231,7 +231,7 @@ def _optional_int(value: object) -> int | None: return None try: return int(str(value)) - except TypeError, ValueError: + except (TypeError, ValueError): return None diff --git a/app/modules/musicbrainz/__init__.py b/app/modules/musicbrainz/__init__.py index c665f649e..d46f3ff5c 100644 --- a/app/modules/musicbrainz/__init__.py +++ b/app/modules/musicbrainz/__init__.py @@ -831,7 +831,7 @@ class MusicBrainzModule(_ModuleBase): """相关度每五分成组,组内应用发行偏好并保留原始得分。""" try: score = int(release.get("score") or 0) - except TypeError, ValueError: + except (TypeError, ValueError): score = 0 region_rank, script_rank = cls._release_preference_sort_key( release, diff --git a/app/modules/themoviedb/__init__.py b/app/modules/themoviedb/__init__.py index 2f5fc6a5e..8671459a5 100644 --- a/app/modules/themoviedb/__init__.py +++ b/app/modules/themoviedb/__init__.py @@ -164,7 +164,7 @@ class TheMovieDbModule(MediaAuxiliaryProviderMixin, _ModuleBase): try: tmdb_id = int(raw_tmdb_id) media_type = MediaType(request.media_type) - except TypeError, ValueError: + except (TypeError, ValueError): return None info = self.tmdb_info(tmdbid=tmdb_id, mtype=media_type) if not info: diff --git a/app/runtime/extensions/module/contracts.py b/app/runtime/extensions/module/contracts.py index 0caf0ec5d..835819d0a 100644 --- a/app/runtime/extensions/module/contracts.py +++ b/app/runtime/extensions/module/contracts.py @@ -1809,7 +1809,7 @@ def diagnose_module_callable(method: str, callback: Callable[..., Any]) -> tuple return () try: parameters = inspect.signature(callback).parameters - except TypeError, ValueError: + except (TypeError, ValueError): return ("signature-unavailable",) missing = tuple( name diff --git a/app/startup/composition/enrichment.py b/app/startup/composition/enrichment.py index 8773eba94..7dd6a8b93 100644 --- a/app/startup/composition/enrichment.py +++ b/app/startup/composition/enrichment.py @@ -120,7 +120,7 @@ class RuntimeClassificationEnrichmentCache: return ClassificationEnrichmentCacheEntry(response=None) try: response = ClassificationEnrichmentResponse.model_validate(value.get("response")) - except TypeError, ValidationError: + except (TypeError, ValidationError): return None return ClassificationEnrichmentCacheEntry(response=response)