fix: Update pyright configuration to include app/api/routers/position* and app/api/routers/token* for type checking
#1747
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 refactors the
app/api/routers/position*.pyandapp/api/routers/token*.pymodule to improve type safety, clarity, and maintainability. The main changes include updating function signatures and variable types to use more precise custom types, ensuring correct handling of boolean flags, and replacing usage of__dict__with a dedicatedto_dict()method for token model serialization. The changes also introduce explicit casting and type annotations for better static analysis and future-proofing.✅ Related Issues
🔄 Changes
Type and Serialization Improvements
PositionDataDictandPositionsResponseDict, ensuring more accurate type checking throughout the codebase. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13]__dict__with theto_dict()method for token model serialization, leading to more controlled and predictable output structures. [1] [2] [3] [4] [5] [6] [7]Boolean and Type Handling
enable_indexandinclude_token_detailsare explicitly cast tobool, preventing potential bugs from incorrect type usage. [1] [2] [3] [4] [5]typing.castfor explicit type conversions when fetching query results, improving type safety and future compatibility with stricter ORM typing. [1] [2] [3] [4]Minor API and Logging Adjustments
ServiceUnavailableexceptions to usestr(e)for better readability. [1] [2] [3]TokenBasemodel type, aligning with current code standards. [1] [2]These changes collectively improve code quality, maintainability, and reliability of the position API logic.
📌 Checklist