44import os
55import re
66import stat
7+ from collections .abc import Iterable , Iterator , Mapping
78from contextlib import closing
89from functools import partial
910from io import BytesIO , StringIO
1011from typing import (
1112 TYPE_CHECKING ,
1213 Any ,
1314 Callable ,
14- Dict ,
15- Iterable ,
16- Iterator ,
17- List ,
18- Mapping ,
1915 Optional ,
20- Tuple ,
2116 Union ,
2217)
2318
@@ -151,18 +146,18 @@ def encoding(self) -> str:
151146 return self ._config .encoding
152147 return self ._config .backends [0 ].encoding
153148
154- def get (self , section : Tuple [str , ...], name : str ) -> str :
149+ def get (self , section : tuple [str , ...], name : str ) -> str :
155150 """Return the specified setting as a string."""
156151 return self ._config .get (section , name ).decode (self .encoding )
157152
158- def get_bool (self , section : Tuple [str , ...], name : str ) -> bool :
153+ def get_bool (self , section : tuple [str , ...], name : str ) -> bool :
159154 """Return the specified setting as a boolean."""
160155 value = self ._config .get_boolean (section , name )
161156 if value is None :
162157 raise ValueError ("setting is not a valid boolean" )
163158 return value
164159
165- def get_multivar (self , section : Tuple [str , ...], name : str ) -> Iterator [str ]:
160+ def get_multivar (self , section : tuple [str , ...], name : str ) -> Iterator [str ]:
166161 """Iterate over string values in the specified multivar setting."""
167162 for value in self ._config .get_multivar (section , name ):
168163 yield value .decode (self .encoding )
@@ -199,17 +194,17 @@ def __init__( # pylint:disable=W0231
199194 except NotGitRepository as exc :
200195 raise SCMError (f"{ root_dir } is not a git repository" ) from exc
201196
202- self ._submodules : Dict [str , str ] = self ._find_submodules ()
197+ self ._submodules : dict [str , str ] = self ._find_submodules ()
203198 self ._stashes : dict = {}
204199
205- def _find_submodules (self ) -> Dict [str , str ]:
200+ def _find_submodules (self ) -> dict [str , str ]:
206201 """Return dict mapping submodule names to submodule paths.
207202
208203 Submodule paths will be relative to Git repo root.
209204 """
210205 from dulwich .config import ConfigFile , parse_submodules
211206
212- submodules : Dict [str , str ] = {}
207+ submodules : dict [str , str ] = {}
213208 config_path = os .path .join (self .root_dir , ".gitmodules" )
214209 if os .path .isfile (config_path ):
215210 config = ConfigFile .from_path (config_path )
@@ -332,7 +327,7 @@ def add(
332327 self .repo .stage (list (self .repo .open_index ()))
333328 return
334329
335- files : List [bytes ] = [
330+ files : list [bytes ] = [
336331 os .fsencode (fpath ) for fpath in self ._expand_paths (paths , force = force )
337332 ]
338333 if update :
@@ -348,7 +343,7 @@ def add(
348343 else :
349344 self .repo .stage (files )
350345
351- def _expand_paths (self , paths : List [str ], force : bool = False ) -> Iterator [str ]:
346+ def _expand_paths (self , paths : list [str ], force : bool = False ) -> Iterator [str ]:
352347 for path in paths :
353348 if not os .path .isabs (path ) and self ._submodules :
354349 # NOTE: If path is inside a submodule, Dulwich expects the
@@ -459,7 +454,7 @@ def is_tracked(self, path: str) -> bool:
459454 return any (p == rel or p .startswith (rel_dir ) for p in self .repo .open_index ())
460455
461456 def is_dirty (self , untracked_files : bool = False ) -> bool :
462- kwargs : Dict [str , Any ] = {} if untracked_files else {"untracked_files" : "no" }
457+ kwargs : dict [str , Any ] = {} if untracked_files else {"untracked_files" : "no" }
463458 return any (self .status (** kwargs ))
464459
465460 def active_branch (self ) -> str :
@@ -707,9 +702,9 @@ def fetch_refspecs(
707702 fetch_refs = []
708703
709704 def determine_wants (
710- remote_refs : Dict [bytes , bytes ],
705+ remote_refs : dict [bytes , bytes ],
711706 depth : Optional [int ] = None , # pylint: disable=unused-argument
712- ) -> List [bytes ]:
707+ ) -> list [bytes ]:
713708 fetch_refs .extend (
714709 parse_reftuples (
715710 DictRefsContainer (remote_refs ),
@@ -782,7 +777,7 @@ def _stash_push(
782777 ref : str ,
783778 message : Optional [str ] = None ,
784779 include_untracked : bool = False ,
785- ) -> Tuple [Optional [str ], bool ]:
780+ ) -> tuple [Optional [str ], bool ]:
786781 from dulwich .repo import InvalidUserIdentity
787782
788783 from scmrepo .git import Stash
@@ -836,8 +831,8 @@ def _describe(
836831 ) -> Mapping [str , Optional [str ]]:
837832 if not base :
838833 base = "refs/tags"
839- rev_mapping : Dict [str , Optional [str ]] = {}
840- results : Dict [str , Optional [str ]] = {}
834+ rev_mapping : dict [str , Optional [str ]] = {}
835+ results : dict [str , Optional [str ]] = {}
841836 for ref in self .iter_refs (base = base ):
842837 if (match and not fnmatch .fnmatch (ref , match )) or (
843838 exclude and fnmatch .fnmatch (ref , exclude )
@@ -877,7 +872,7 @@ def checkout_index(
877872
878873 def status (
879874 self , ignored : bool = False , untracked_files : str = "all"
880- ) -> Tuple [Mapping [str , Iterable [str ]], Iterable [str ], Iterable [str ]]:
875+ ) -> tuple [Mapping [str , Iterable [str ]], Iterable [str ], Iterable [str ]]:
881876 from dulwich .porcelain import Error
882877 from dulwich .porcelain import status as git_status
883878
@@ -978,7 +973,7 @@ def check_attr(
978973_IDENTITY_RE = re .compile (r"(?P<name>.+)\s+<(?P<email>.+)>" )
979974
980975
981- def _parse_identity (identity : str ) -> Tuple [str , str ]:
976+ def _parse_identity (identity : str ) -> tuple [str , str ]:
982977 m = _IDENTITY_RE .match (identity )
983978 if not m :
984979 raise SCMError ("Could not parse tagger identity '{identity}'" )
0 commit comments