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

refactor!: BaseProject to abstract base class, registration pattern #370

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions libvcs/projects/base.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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: Optional[StrPath]
"""CWD of project"""

def __init__(self, *, url: str, dir: StrPath, progress_callback=None, **kwargs):
r"""
Parameters
Expand Down Expand Up @@ -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:
Expand Down