Skip to content

typing fixes - DiffIndex generic type and IndexFile items - #1925

Merged
Byron merged 2 commits into
gitpython-developers:mainfrom
Andrej730:main
Jun 3, 2024
Merged

typing fixes - DiffIndex generic type and IndexFile items#1925
Byron merged 2 commits into
gitpython-developers:mainfrom
Andrej730:main

Conversation

@Andrej730

Copy link
Copy Markdown
Contributor

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)
Andrej730 added 2 commits June 3, 2024 00:32
Error before commit:

path: os.PathLike = ...
repo = git.Repo(path_dir)
repo.index.add(path)
Example before this commit:

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]

@Byron Byron left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the typing fix, it's much appreciated.

@Byron
Byron merged commit e51bfdf into gitpython-developers:main Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants