Skip to content

Add pydantic models for borg 1.x's CLI (#8338) #8343

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

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

Conversation

a-gn
Copy link

@a-gn a-gn commented Aug 26, 2024

This adds pydantic models for borg's CLI outputs (fixes #8338).

Sadly I can't try to run these tests locally; when trying to run tox or pip install borg I get OSError: pkg-config probably not installed: FileNotFoundError(2, 'No such file or directory').

@@ -24,9 +25,15 @@ def __init__(self, msgid=None):
self.id = self.operation_id()
self.msgid = msgid

def make_json(self, *, finished=False, **kwargs):
def make_json(self, *, finished=False, override_time: typing.Optional[float] = None, **kwargs):
Copy link
Author

Choose a reason for hiding this comment

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

Let me know if you think this new argument is bad. The function is harder to test when it always takes time.time().

@a-gn
Copy link
Author

a-gn commented Aug 31, 2024

@ThomasWaldmann I just fixed the Python 3.10 union syntax, hopefully that's the last of it.

@ThomasWaldmann
Copy link
Member

Looks like mypy is unhappy.

@a-gn
Copy link
Author

a-gn commented Mar 10, 2025

Looks like mypy is unhappy.

mypy: commands[0]> mypy --ignore-missing-imports
src/borg/helpers/shellpattern.py:88: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
src/borg/public/cli_api/v1.py:15: error: Module "typing" has no attribute "Self"  [attr-defined]
src/borg/public/cli_api/v1.py:15: note: Use `from typing_extensions import Self` instead
src/borg/public/cli_api/v1.py:15: note: See https://mypy.readthedocs.io/en/stable/runtime_troubles.html#using-new-additions-to-the-typing-module
src/borg/public/cli_api/v1.py:115: error: Invalid type alias: expression is not a valid type  [valid-type]
src/borg/public/cli_api/v1.py:115: error: Unsupported left operand type for | ("type[ArchiveProgressLogLine]")  [operator]

I might have left some Python 3.10-specific things in there, sorry! Will fix them when I have time. Also maybe there are some missing hints.

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.

Docs suggestion: pydantic models for borg's JSON output
2 participants