Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Closed
@itsayellow

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.

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