fix: replace 3 bare except clauses with except Exception#815
Open
KeloYuan wants to merge 1 commit into
Open
Conversation
Changed: utils/cleaners.py, inference/auto_model.py, fix_mismatch.py
There was a problem hiding this comment.
Pull request overview
This PR aims to make exception handling safer and more explicit by replacing three bare except: clauses with except Exception: across the codebase.
Changes:
- Updated optional import handling for
german_transliterateintensorflow_tts/utils/cleaners.py. - Updated weight-loading fallback logic in
tensorflow_tts/inference/auto_model.py. - Updated duration-file loading fallback logic in
examples/mfa_extraction/fix_mismatch.py.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tensorflow_tts/utils/cleaners.py | Replaces a bare import except: with except Exception: for optional German transliteration dependency. |
| tensorflow_tts/inference/auto_model.py | Replaces a bare except: around load_weights with except Exception: before attempting a fallback load mode. |
| examples/mfa_extraction/fix_mismatch.py | Replaces a bare except: when loading trimmed durations with except Exception: and falls back to untrimmed durations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+30
to
31
| except Exception: | ||
| pass |
Comment on lines
105
to
111
| if pretrained_path is not None and ".h5" in pretrained_path: | ||
| try: | ||
| model.load_weights(pretrained_path) | ||
| except: | ||
| except Exception: | ||
| model.load_weights( | ||
| pretrained_path, by_name=True, skip_mismatch=True | ||
| ) |
| os.path.join(trimmed_dur_path, f"{i.split('-')[0]}-durations.npy") | ||
| ) | ||
| except: | ||
| except Exception: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces 3 bare
except:withexcept Exception:inutils/cleaners.py,inference/auto_model.py,examples/mfa_extraction/fix_mismatch.py.