refactor: fix implicit Optional type hints in utils.py#2482
Open
tusharynayaka wants to merge 3 commits intoborgbase:masterfrom
Open
refactor: fix implicit Optional type hints in utils.py#2482tusharynayaka wants to merge 3 commits intoborgbase:masterfrom
tusharynayaka wants to merge 3 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 PR resolves Mypy errors regarding implicit Optional type hints in src/vorta/utils.py. In accordance with PEP 484 and modern Mypy standards, arguments that default to None now use explicit Optional[...] or | None syntax. This ensures the codebase remains compatible with strict static analysis.
Related Issue:
Relates to GSoC 2026 Project: "Add comprehensive type annotations."
Motivation and Context:
Implicit Optional types are no longer supported by recent versions of Mypy. By making these types explicit, we improve code clarity and prevent potential NoneType attribute errors during development. This is a foundational step toward full type-check compliance for the project.
How Has This Been Tested?
Static Analysis: Verified the module using mypy.
Unit Tests: Ran the dedicated utility test suite.
Command: pytest tests/unit/test_utils.py -k "not keyring and not system_tray"
Results: 26 tests passed successfully.
Environment: WSL (Ubuntu 24.04), Python 3.12.3.
Types of changes
[x] Bug fix (non-breaking change which fixes an issue)
Checklist:
[x] I have read the guide.
[x] My code follows the code style of this project.
[x] My change requires a change to the documentation.
[x] I have updated the documentation accordingly.
[x] I have added tests to cover my changes.
[x] All new and existing tests passed.