Skip to content

Commit 0dc9de6

Browse files
committed
chore: Typing map for str -> repo class
1 parent 741a043 commit 0dc9de6

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

libvcs/shortcuts.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
"""Shortcuts"""
2-
from typing import Union
2+
from typing import Dict, Literal, Type, Union
33

44
from libvcs import GitRepo, MercurialRepo, SubversionRepo
55
from libvcs.exc import InvalidPipURL, InvalidVCS
66

7+
#: Default VCS systems by string (in :data:`DEFAULT_VCS_CLASS_MAP`)
8+
DEFAULT_VCS_LITERAL = Literal["git", "hg", "svn"]
9+
#: Union of VCS Classes
10+
DEFAULT_VCS_CLASS_UNION = Type[Union[GitRepo, MercurialRepo, SubversionRepo]]
11+
#: String -> Class Map. ``DEFAULT_VCS_CLASS_MAP['git']`` -> :class:`~libvcs.git.GitRepo`
12+
DEFAULT_VCS_CLASS_MAP: Dict[DEFAULT_VCS_LITERAL, DEFAULT_VCS_CLASS_UNION] = {
13+
"git": GitRepo,
14+
"svn": SubversionRepo,
15+
"hg": MercurialRepo,
16+
}
17+
718

819
def create_repo(
920
url, vcs, progress_callback=None, **kwargs

0 commit comments

Comments
 (0)