11# -*- coding: utf-8 -*-
22
3- import sys
43from os import PathLike
54from pathlib import Path
5+ from typing import Union
66
77from pygit2 import Oid
88from pygit2 import Repository as _Repository
@@ -25,7 +25,9 @@ class Repository(_Repository):
2525 Apache License, Version 2.0
2626 """
2727
28- def __init__ (self , git_directory = "." , logger = None , ** kwargs ):
28+ def __init__ (
29+ self , git_directory : Union [str , PathLike [str ]] = "." , logger = None , ** kwargs
30+ ):
2931 """
3032 Constructor __init__(Repository)
3133
@@ -38,8 +40,7 @@ def __init__(self, git_directory=".", logger=None, **kwargs):
3840 if logger is None or not logger .hasHandlers ():
3941 logger = LoggerSetup .get_logger ("gardenlinux.git" )
4042
41- if not isinstance (git_directory , PathLike ):
42- git_directory = Path (git_directory )
43+ git_directory = Path (git_directory )
4344
4445 if not git_directory .exists ():
4546 raise RuntimeError (f"Git directory given is invalid: { git_directory } " )
@@ -107,11 +108,11 @@ def root_repo(self):
107108
108109 @staticmethod
109110 def checkout_repo (
110- git_directory ,
111+ git_directory : Union [ str , PathLike [ str ]] ,
111112 repo_url = GL_REPOSITORY_URL ,
112- branch = "main" ,
113- commit = None ,
114- pathspecs = None ,
113+ branch : str = "main" ,
114+ commit : str | None = None ,
115+ pathspecs : list [ str ] | None = None ,
115116 logger = None ,
116117 ** kwargs ,
117118 ):
@@ -122,8 +123,7 @@ def checkout_repo(
122123 :since: 0.10.0
123124 """
124125
125- if not isinstance (git_directory , PathLike ):
126- git_directory = Path (git_directory )
126+ git_directory = Path (git_directory )
127127
128128 if not git_directory .is_dir () or git_directory .match ("/*" ):
129129 raise RuntimeError (
0 commit comments