Repository navigation
more assert - #24996
Merged
Merged
more assert#24996
Conversation
Contributor
Author
|
why all > assert isinstance(current_user, Account) and current_user.timezone is not None
E AssertionError |
laipz8200
requested changes
Sep 3, 2025
Signed-off-by: -LAN- <laipz8200@outlook.com>
Signed-off-by: -LAN- <laipz8200@outlook.com>
asukaminato0721
force-pushed
the
more-assert
branch
from
September 5, 2025 12:09
6c75b6a to
99c8c99
Compare
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds type checking assertions to services that use current_user throughout the Dify codebase. The changes enhance runtime type safety by asserting that current_user is an instance of Account and that required attributes like current_tenant_id and timezone are not None where they are expected to exist.
- Replaces mock usage patterns in tests with
create_autospec(Account, instance=True)for better type safety - Adds runtime assertions for
current_userbeing anAccountinstance and having required non-None attributes - Updates import statements to use
libs.login.current_userinstead offlask_login.current_user
Reviewed Changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| test files (*.py) | Replace Mock() with create_autospec(Account, instance=True) for current_user mocking |
| service files (*.py) | Add runtime assertions for current_user type and required attributes |
| controllers/console/billing/billing.py | Add type assertions and null-safe string concatenation |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
crazywoola
approved these changes
Sep 8, 2025
6 tasks done
Ssazurov
pushed a commit
to Ssazurov/dify
that referenced
this pull request
Aug 8, 2026
Signed-off-by: -LAN- <laipz8200@outlook.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: -LAN- <laipz8200@outlook.com> Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com>
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.
Important
Fixes #<issue number>.part of #24406
Summary
Screenshots
Checklist
dev/reformat(backend) andcd web && npx lint-staged(frontend) to appease the lint gods