chore: add encoding= to open() and type hints (9 files)#9
Open
mangodxd wants to merge 1 commit intoGPT-AGI:mainfrom
Open
chore: add encoding= to open() and type hints (9 files)#9mangodxd wants to merge 1 commit intoGPT-AGI:mainfrom
mangodxd wants to merge 1 commit intoGPT-AGI:mainfrom
Conversation
Owner
|
Thanks for the PR — really appreciate the cleanup work. I’d suggest splitting this into two smaller PRs:
I’d be less eager to take broad type-hint changes in dynamic provider methods unless the annotations are very precise. |
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.
Hello,
I noticed a few areas where the code could be made a bit more robust and readable. This PR focuses on minor housekeeping tasks and does not change any of the existing runtime logic:
Explicit encoding for file operations
session.py: addedencoding="utf-8"to 2open()call(s)I added explicit encoding here because Python's default behavior depends on the operating system. This change ensures the code handles text consistently whether it is running on Windows, Linux, or macOS, preventing potential UnicodeDecodeErrors.
Type hint additions
anthropic_provider.py: added type hints to 3 function(s)base.py: added type hints to 2 function(s)cli.py: added type hints to 4 function(s)conversation.py: added type hints to 5 function(s)core.py: added type hints to 14 function(s)minimax_provider.py: added type hints to 3 function(s)openai_compatible.py: added type hints to 2 function(s)query_engine.py: added type hints to 1 function(s)session.py: added type hints to 1 function(s)I have added basic type annotations based on variable names and default values. This should make the code easier to work with in modern IDEs without changing any of the actual logic.
Examples of changes
Example change in
anthropic_provider.py:Example change in
base.py:Safety and verification
ast.parse()to ensure no syntax errors were introduced.eval()orglobals()were automatically skipped.__init__.pyfiles.I hope these small improvements are helpful for the project.