Fix new mypy error in is_cygwin_git · gitpython-developers/GitPython@42e10c0

Original file line numberDiff line numberDiff line change

@@ -448,25 +448,7 @@ def decygpath(path: PathLike) -> str:

448448

_is_cygwin_cache: Dict[str, Optional[bool]] = {}

449449
450450
451-

@overload

452-

def is_cygwin_git(git_executable: None) -> Literal[False]:

453-

...

454-
455-
456-

@overload

457-

def is_cygwin_git(git_executable: PathLike) -> bool:

458-

...

459-
460-
461-

def is_cygwin_git(git_executable: Union[None, PathLike]) -> bool:

462-

if sys.platform == "win32":

463-

# This is Windows-native Python, since Cygwin has sys.platform == "cygwin".

464-

return False

465-
466-

if git_executable is None:

467-

return False

468-
469-

git_executable = str(git_executable)

451+

def _is_cygwin_git(git_executable: str) -> bool:

470452

is_cygwin = _is_cygwin_cache.get(git_executable) # type: Optional[bool]

471453

if is_cygwin is None:

472454

is_cygwin = False

@@ -489,6 +471,25 @@ def is_cygwin_git(git_executable: Union[None, PathLike]) -> bool:

489471

return is_cygwin

490472
491473
474+

@overload

475+

def is_cygwin_git(git_executable: None) -> Literal[False]:

476+

...

477+
478+
479+

@overload

480+

def is_cygwin_git(git_executable: PathLike) -> bool:

481+

...

482+
483+
484+

def is_cygwin_git(git_executable: Union[None, PathLike]) -> bool:

485+

if sys.platform == "win32": # TODO: See if we can use `sys.platform != "cygwin"`.

486+

return False

487+

elif git_executable is None:

488+

return False

489+

else:

490+

return _is_cygwin_git(str(git_executable))

491+
492+
492493

def get_user_id() -> str:

493494

""":return: String identifying the currently active system user as ``name@node``"""

494495

return "%s@%s" % (getpass.getuser(), platform.node())