-
Notifications
You must be signed in to change notification settings - Fork 0
fix: Add type annotations to fix pyright type errors in batch/, app/main.py, app/config.py and misc files
#1736
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
Conversation
… `app/config.py` etc
…rious functions for improved type checking
| LOG.info("Syncing to={}".format(block_to)) | ||
|
|
||
| await self.__sync_transfer(db_session, block_to) | ||
| await self.__sync_consume(db_session, block_to) |
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.
Unfortunately, I found a bug in the existing logic: the processing related to __sync_consume is not being executed.
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.
Pull request overview
This pull request focuses on improving type safety and code quality by adding comprehensive type annotations, simplifying configuration handling, and removing unused code. The changes target type errors detected by Pyright across batch processing modules, configuration files, and various utilities.
Changes:
- Added comprehensive type annotations to batch indexers, processors, and utility modules including proper typing for Web3 event data, contracts, and blockchain interactions
- Simplified environment variable parsing in
app/config.pyusing more conciseint(os.environ.get("VAR") or default)pattern, reducing code verbosity - Refactored company data handling from property-based
Companyclass to TypedDict-based approach for better type safety and simpler data access - Removed unused utility code including
app/utils/alchemy.py, unused FIELDS dictionaries in database models, and deprecated helper functions
Reviewed changes
Copilot reviewed 69 out of 70 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| uv.lock, pyproject.toml | Added types-botocore dependency for boto3 type stubs |
| pyrightconfig.json | Extended Pyright coverage to include app/ and batch/ directories |
| batch/* files | Added type annotations for event data, contracts, function signatures, and return types |
| app/config.py | Simplified environment variable parsing and added pyright directive |
| app/utils/company_list.py | Refactored Company from class to TypedDict for better type safety |
| app/model/db/* | Removed unused FIELDS dictionaries from all database models |
| app/contracts/*.py | Added proper type annotations for contract interactions |
| app/main.py, app/errors.py | Added return type annotations to exception handlers and error classes |
| app/utils/*.py | Enhanced type annotations in utility modules |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…` and add comment for error handling in `indexer_Transfer.py`
📌 Description
This pull request focuses on type improvements, code cleanup, and simplification across several modules, with a particular emphasis on more precise type annotations, more idiomatic environment variable handling in configuration, and some minor bug fixes. The changes aim to make the codebase more robust, readable, and maintainable.
✅ Related Issues
🔄 Changes
Type Annotations and Model Improvements
Added or improved type annotations in various places for better static analysis and code clarity, including the use of
Any,Type[Any],list[Type[BaseModel]], and more explicit types for cache and function arguments inapp/contracts/abi.pyandapp/contracts/contract.py. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]Fixed and clarified usage of the
Companytype in API router and utility functions, ensuring consistent and correct typing for company objects. [1] [2] [3] [4] [5]Configuration Simplification
app/config.pyby replacing verbose conditional expressions with a more conciseint(os.environ.get("VAR") or default)pattern, improving readability and reducing code duplication. [1] [2] [3] [4] [5] [6] [7] [8]Imports and Linting
app/config.pyandapp/contracts/__init__.pyfor better static analysis compatibility. [1] [2]Minor Bug Fixes and Cleanups
.json().These changes collectively enhance code safety, maintainability, and clarity while fixing minor issues and ensuring more robust handling of data and configuration.
📌 Checklist