Skip to content

repo.index.add() first argument type accepts os.PathLike but code raises TypeError #1382

Description

@itsayellow

In the docs and in the code types, the first argument for repo.index.add() is Sequence[Union[str, os.PathLike, git.objects.blob.Blob, git.index.typ.BaseIndexEntry, Submodule]].
However, actually trying to submit a list of Paths to this argument results in a TypeError, as it seems the code inside _preprocess_add_items does not handle Paths.

I think this could be fixed by changing line 611 inside of _preprocess_add_items in base.py to:

 if isinstance(item, str) or isinstance(item, os.PathLike):

if isinstance(item, str):

Since _to_relative_path() already accepts pathlike arguments.

Activity

  1. Byron commented on Dec 19, 2021

    @Byron
    Member

    Thanks a lot for the summary and the suggestion for a fix. A PR is definitely welcome.

  2. added 6 commits that reference this issue on May 17, 2022
    0c43ee3
    d50bc88
    392c72c
    5e56226
    8232b17
    a2e297a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions