typing: improve type safety in utils.py and application.py.#2486
Open
ExeWall wants to merge 5 commits intoborgbase:masterfrom
Open
typing: improve type safety in utils.py and application.py.#2486ExeWall wants to merge 5 commits intoborgbase:masterfrom
ExeWall wants to merge 5 commits intoborgbase:masterfrom
Conversation
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.
Description
This pull request introduces type annotations and strengthens type safety in two core files:
utils.pyandapplication.py.Key changes:
src/vorta/utils.py: Added type hints to thesearchfunction andFilePathInfoAsyncclass. Improved the logic ofsearchto handle optional callables correctly.src/vorta/application.py: FixedNoneTypeerrors reported by Mypy regardingconfig.TEMP_DIRandconfig.LOG_DIR. Added defensive checks (type narrowing) to ensure path operations and.as_uri()calls only occur when the paths are notNone.Related Issue
This is a proactive improvement to address static analysis warnings and prevent potential runtime crashes (NoneType errors). It aligns with the project's goal of gradual typing.
Motivation and Context
The main motivation is to improve code maintainability and robustness. By resolving
NoneTypeissues inapplication.py, we prevent crashes that could occur if environment-dependent directories are not yet initialized. This is part of my preparation for GSoC 2026.How Has This Been Tested?
The changes were verified using Mypy 1.x in a local development environment.
mypy src/vorta/utils.py-> Result: Successmypy src/vorta/application.py-> Result: SuccessTypes of changes
Checklist: