gitpython-developers / GitPython

GitPython is a python library used to interact with Git repositories.
http://gitpython.readthedocs.org
BSD 3-Clause "New" or "Revised" License
4.6k stars 905 forks source link

typing fixes - DiffIndex generic type and IndexFile items #1925

Closed Andrej730 closed 4 months ago

Andrej730 commented 4 months ago

Example issue with DiffIndex:

repo = git.Repo(path_dir)
diff = repo.index.diff(None)
modified_files = [d for d in repo.index.diff(None)]
reveal_type(modified_files) # list[Unknown] instead of list[Diff]

Example issue with IndexFile:

path: os.PathLike = ...
repo = git.Repo(path_dir)
# Argument of type "PathLike[Unknown]"
# cannot be assigned to parameter "items" of type "Sequence[git.types.PathLike | Blob | BaseIndexEntry | Submodule]" in function "add"
# "PathLike[Unknown]" is incompatible with "Sequence[git.types.PathLike | Blob | BaseIndexEntry | Submodule]"
repo.index.add(path)