-
Notifications
You must be signed in to change notification settings - Fork 13.4k
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
Feat: pyright helps dify remove dead var and func #16741
base: main
Are you sure you want to change the base?
Conversation
7062c7a
to
ecb3d4f
Compare
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.
I have commented on some areas that need modifications, not all of them. Please check all similar issues.
api/commands.py
Outdated
@@ -561,7 +561,7 @@ def old_metadata_migration(): | |||
for document in documents: | |||
if document.doc_metadata: | |||
doc_metadata = document.doc_metadata | |||
for key, value in doc_metadata.items(): | |||
for key, _ in doc_metadata.items(): |
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.
for key, _ in doc_metadata.items(): | |
for key in doc_metadata: |
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.
Done at commit 86aed5b
@@ -122,7 +122,7 @@ def post(self): | |||
language = "en-US" | |||
try: | |||
account = AccountService.get_user_through_email(args["email"]) | |||
except AccountRegisterError as are: | |||
except AccountRegisterError: | |||
raise AccountInFreezeError() |
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.
raise AccountInFreezeError() | |
raise AccountInFreezeError() from are |
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.
Done at commit c5710e8
@@ -153,7 +153,7 @@ def post(self): | |||
language = "en-US" | |||
try: | |||
account = AccountService.get_user_through_email(args["email"]) | |||
except AccountRegisterError as are: | |||
except AccountRegisterError: | |||
raise AccountInFreezeError() |
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.
raise AccountInFreezeError() | |
raise AccountInFreezeError() from are |
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.
Done at commit c5710e8
api/controllers/console/wraps.py
Outdated
@@ -175,7 +175,7 @@ def decorated(*args, **kwargs): | |||
if utm_info: | |||
utm_info_dict: dict = json.loads(utm_info) | |||
OperationService.record_utm(current_user.current_tenant_id, utm_info_dict) | |||
except Exception as e: | |||
except Exception: | |||
pass |
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.
I think it's better to print logs here.
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.
Done at commit ccb4072
@JohnJyong |
Summary
I propose to use pyright to detect unused functions and code automatically.
This is the config file
pyrightconfig.json
.Tip
Close issue syntax:
Fixes #<issue number>
orResolves #<issue number>
, see documentation for more details.Screenshots
Checklist
Important
Please review the checklist below before submitting your pull request.
dev/reformat
(backend) andcd web && npx lint-staged
(frontend) to appease the lint gods