typing: improve type safety in utils.py, application.py and models.py.#2486
Open
ExeWall wants to merge 5 commits intoborgbase:masterfrom
Open
typing: improve type safety in utils.py, application.py and models.py.#2486ExeWall wants to merge 5 commits intoborgbase:masterfrom
ExeWall wants to merge 5 commits intoborgbase:masterfrom
Conversation
Author
|
@m3nu can you review when you have time? Thank you so much. |
Author
|
@m3nu, hiii, can you review when you have time? Thank you so much. |
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 across three core modules of the Vorta codebase to improve maintainability and prevent runtime errors.
Changes in detail:
src/vorta/utils.py: Added type hints to thesearchfunction andFilePathInfoAsyncclass. Improved logic to handle optional callables correctly.src/vorta/application.py: ResolvedNoneTypevulnerabilities by adding defensive checks (type narrowing) before path operations and.as_uri()calls.src/vorta/store/models.py: Fixed an incompatible type assignment between SQLAlchemyStringExpressionand standardstrby explicitly casting the pattern to a string.Related Issue
This is a proactive improvement to address static analysis warnings and align with the project's move toward gradual typing. It also serves as my initial contribution for the GSoC 2026 application.
Motivation and Context
The main goal is to improve code robustness. By resolving these Mypy-reported issues, we prevent potential crashes (especially
AttributeErroronNoneType) that could occur if environment-dependent directories or database expressions are not handled safely.How Has This Been Tested?
The changes were verified using Mypy 1.x in a local environment:
mypy src/vorta/utils.py-> Success.mypy src/vorta/application.py-> Success.mypy src/vorta/store/models.py-> Success.Types of changes
Checklist:
I provide my contribution under the terms of the license of this repository and I affirm the Developer Certificate of Origin.