-
Notifications
You must be signed in to change notification settings - Fork 20.7k
fix: replace bare except clauses with except Exception #33426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,7 +34,7 @@ def reset_password(email, new_password, password_confirm): | |
|
|
||
| try: | ||
| valid_password(new_password) | ||
| except: | ||
| except Exception: | ||
| click.echo(click.style(f"Invalid password. Must match {password_pattern}", fg="red")) | ||
| return | ||
|
|
||
|
|
@@ -74,7 +74,7 @@ def reset_email(email, new_email, email_confirm): | |
|
|
||
| try: | ||
| email_validate(normalized_new_email) | ||
| except: | ||
| except Exception: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| click.echo(click.style(f"Invalid email: {new_email}", fg="red")) | ||
| return | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,7 +49,7 @@ def extra_json_from_code_block(code_block) -> list[Union[list, dict]]: | |
| json_text = re.sub(r"^[a-zA-Z]+\n", "", block.strip(), flags=re.MULTILINE) | ||
| json_blocks.append(json.loads(json_text, strict=False)) | ||
| return json_blocks | ||
| except: | ||
| except Exception: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| return [] | ||
|
|
||
| code_block_cache = "" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,7 +57,7 @@ def __init__(self, collection_name: str, config: AnalyticdbVectorOpenAPIConfig): | |
| try: | ||
| from alibabacloud_gpdb20160503.client import Client # type: ignore | ||
| from alibabacloud_tea_openapi import models as open_api_models # type: ignore | ||
| except: | ||
| except Exception: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| raise ImportError(_import_err_msg) | ||
| self._collection_name = collection_name.lower() | ||
| self.config = config | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -231,7 +231,7 @@ def text_exists(self, id: str) -> bool: | |||||
| params["routing"] = self._routing | ||||||
| self._client.get(index=self._collection_name, id=id, params=params) | ||||||
| return True | ||||||
| except: | ||||||
| except Exception: | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
|
||||||
| return False | ||||||
|
|
||||||
| def search_by_vector(self, query_vector: list[float], **kwargs: Any) -> list[Document]: | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -167,7 +167,7 @@ def text_exists(self, id: str) -> bool: | |||||
| try: | ||||||
| self._client.get(index=self._collection_name.lower(), id=id) | ||||||
| return True | ||||||
| except: | ||||||
| except Exception: | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to the Lindorm vector store,
Suggested change
|
||||||
| return False | ||||||
|
|
||||||
| def search_by_vector(self, query_vector: list[float], **kwargs: Any) -> list[Document]: | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -80,7 +80,7 @@ def exists(self, filename): | |||||||||||||||||
| try: | ||||||||||||||||||
| self.client.head_object(Bucket=self.bucket_name, Key=filename) | ||||||||||||||||||
| return True | ||||||||||||||||||
| except: | ||||||||||||||||||
| except Exception: | ||||||||||||||||||
| return False | ||||||||||||||||||
|
Comment on lines
+83
to
84
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
|
||||||||||||||||||
|
|
||||||||||||||||||
| def delete(self, filename: str): | ||||||||||||||||||
|
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -52,7 +52,7 @@ def exists(self, filename): | |||||||||||||||||
| try: | ||||||||||||||||||
| self.client.head_object(Bucket=self.bucket_name, Key=filename) | ||||||||||||||||||
| return True | ||||||||||||||||||
| except: | ||||||||||||||||||
| except Exception: | ||||||||||||||||||
| return False | ||||||||||||||||||
|
Comment on lines
+55
to
56
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This client behaves similarly to the AWS S3 client. The
Suggested change
|
||||||||||||||||||
|
|
||||||||||||||||||
| def delete(self, filename: str): | ||||||||||||||||||
|
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -409,7 +409,7 @@ def get_app_meta(self, app_model: App): | |||||
| if provider is None: | ||||||
| raise ValueError(f"provider not found for tool {tool_name}") | ||||||
| meta["tool_icons"][tool_name] = json.loads(provider.icon) | ||||||
| except: | ||||||
| except Exception: | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This
Suggested change
|
||||||
| meta["tool_icons"][tool_name] = {"background": "#252525", "content": "\ud83d\ude01"} | ||||||
|
|
||||||
| return meta | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While
except Exception:is better than a bareexcept:, we can be more specific here. Thevalid_passwordfunction raises aValueErroron failure. CatchingValueErrorspecifically makes the code clearer and safer.