Skip to content

typing: improve type safety in utils.py and application.py.#2486

Open
ExeWall wants to merge 5 commits intoborgbase:masterfrom
ExeWall:master
Open

typing: improve type safety in utils.py and application.py.#2486
ExeWall wants to merge 5 commits intoborgbase:masterfrom
ExeWall:master

Conversation

@ExeWall
Copy link
Copy Markdown

@ExeWall ExeWall commented Mar 29, 2026

Description

This pull request introduces type annotations and strengthens type safety in two core files: utils.py and application.py.

Key changes:

  • src/vorta/utils.py: Added type hints to the search function and FilePathInfoAsync class. Improved the logic of search to handle optional callables correctly.
  • src/vorta/application.py: Fixed NoneType errors reported by Mypy regarding config.TEMP_DIR and config.LOG_DIR. Added defensive checks (type narrowing) to ensure path operations and .as_uri() calls only occur when the paths are not None.

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 NoneType issues in application.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.

  • Ran mypy src/vorta/utils.py -> Result: Success
  • Ran mypy src/vorta/application.py -> Result: Success
  • Environment: Python 3.10+ on Windows.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have read the CONTRIBUTING guide.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant