From 1191665264984c1af18e9dde92e1fdff48b6194d Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Mon, 30 May 2022 17:29:11 -0500 Subject: [PATCH 1/2] refactor!: BaseProject to abstract base class --- libvcs/projects/base.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libvcs/projects/base.py b/libvcs/projects/base.py index bab3778a..ef157d4c 100644 --- a/libvcs/projects/base.py +++ b/libvcs/projects/base.py @@ -1,7 +1,7 @@ """Base class for VCS Project plugins.""" import logging import pathlib -from typing import NamedTuple, Optional, Tuple +from typing import NamedTuple, Optional, Protocol, Tuple from urllib import parse as urlparse from libvcs._internal.run import CmdLoggingAdapter, run @@ -32,18 +32,21 @@ def convert_pip_url(pip_url: str) -> VCSLocation: return VCSLocation(url=url, rev=rev) -class BaseProject: +class BaseProject(Protocol): """Base class for repositories.""" - log_in_real_time = None + log_in_real_time: bool """Log command output to buffer""" - bin_name = "" + bin_name: str """VCS app name, e.g. 'git'""" schemes: Tuple[str, ...] = () """List of supported schemes to register in ``urlparse.uses_netloc``""" + dir: StrPath + """CWD of project""" + def __init__(self, *, url: str, dir: StrPath, progress_callback=None, **kwargs): r""" Parameters @@ -85,7 +88,6 @@ def __init__(self, *, url: str, dir: StrPath, progress_callback=None, **kwargs): self.progress_callback = progress_callback #: Directory to check out - self.dir: pathlib.Path if isinstance(dir, pathlib.Path): self.dir = dir else: From c62f6860907b2eb0603988a9c52725464eb728c9 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Mon, 30 May 2022 19:26:16 -0500 Subject: [PATCH 2/2] !squash tweak --- libvcs/projects/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libvcs/projects/base.py b/libvcs/projects/base.py index ef157d4c..e1b4d777 100644 --- a/libvcs/projects/base.py +++ b/libvcs/projects/base.py @@ -44,7 +44,7 @@ class BaseProject(Protocol): schemes: Tuple[str, ...] = () """List of supported schemes to register in ``urlparse.uses_netloc``""" - dir: StrPath + dir: Optional[StrPath] """CWD of project""" def __init__(self, *, url: str, dir: StrPath, progress_callback=None, **kwargs):