fix: Add type annotations to fix pyright type errors in app/model/ #1745
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.
📌 Description
This pull request introduces several improvements and refactorings across the codebase, focusing on code style, timezone handling, type annotations, and code deduplication. The most significant changes include centralizing timezone conversion utilities, improving type safety and clarity in schema definitions, and cleaning up unused or redundant code.
These changes collectively improve maintainability, consistency, and type safety throughout the project.
✅ Related Issues
🔄 Changes
Timezone Handling and Utilities:
replace_to_local_tzandformat_timestamp) inBaseclass ofapp/model/db/base.py, replacing similar duplicated methods in multiple models. This reduces code duplication and ensures consistency in timestamp handling. [1] [2] [3] [4] [5] [6] [7]Type Annotations and Pydantic Schema Improvements:
dict[str, Any],list[object], and explicit return types for methods and validators. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]ConfigDictandField(default_factory=...), and refined model inheritance for generics. [1] [2] [3]General Code Quality and Maintenance:
# pyright: reportUnusedImport=falseto several__init__.pyfiles to suppress unused import warnings, improving code linting experience. [1] [2] [3] [4] [5]Other Notable Changes:
valuetovalue_inListAllLockedSortItemandLockEventSortItemto avoid potential conflicts with reserved keywords. [1] [2]📌 Checklist