Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typing: src/vorta/store #1872

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open

typing: src/vorta/store #1872

wants to merge 22 commits into from

Conversation

SAMAD101
Copy link
Collaborator

Description

To improve readability a bit, and towards making the codebase typesafe.

Related Issue

#1870

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.

I provide my contribution under the terms of the license of this repository and I affirm the Developer Certificate of Origin.

requirements.d/dev.txt Outdated Show resolved Hide resolved
src/vorta/store/connection.py Outdated Show resolved Hide resolved
src/vorta/store/connection.py Outdated Show resolved Hide resolved
src/vorta/store/models.py Outdated Show resolved Hide resolved
@SAMAD101 SAMAD101 changed the title Refactored some parts of src/vorta/store Refactored some parts of src/vorta/store for typesafety Feb 4, 2024
Copy link
Collaborator

@real-yfprojects real-yfprojects left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good progress. Typing is hard but valuable!

@@ -62,12 +63,12 @@ def init_db(con=None):
# Delete old log entries after 6 months.
# The last `create` command of each profile must not be deleted
# since the scheduler uses it to determine the last backup time.
last_backups_per_profile = (
last_backups_per_profile = Tuple(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is proper use of type hints. Shouldn't it be the following instead?

Suggested change
last_backups_per_profile = Tuple(
last_backups_per_profile : Tuple =

Copy link
Collaborator Author

@SAMAD101 SAMAD101 Apr 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

last_scheduled_backups_per_profile just a bit below (line 71) was assigned like that ( = Tuple(...)) so, I did it to last_backups_per_profile for consistency. I think it would be better to do it according to your suggestion or keep both like:

last_backups_per_profile: Tuple = Tuple(

src/vorta/store/connection.py Show resolved Hide resolved
@@ -15,7 +17,7 @@
)


def run_migrations(current_schema, db_connection):
def run_migrations(current_schema: Any, db_connection: SqliteDatabase):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have to specify Any? Isn't it the default, implicit type hint?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I left that one undone. It should be SchemVersion from vorta.store.models

@SAMAD101 SAMAD101 changed the title Refactored some parts of src/vorta/store for typesafety typing: src/vorta/store Apr 11, 2024
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.

None yet

3 participants