libgit2 / pygit2

Python bindings for libgit2
https://www.pygit2.org/
Other
1.61k stars 385 forks source link

`pygit2.remote.RemoteCollection` should implement `__contains__()` to match with valid remote names #1080

Open imbuedhope opened 3 years ago

imbuedhope commented 3 years ago

As it stands the following happens

>>> import os, pygit2
>>> r = pygit2.Repository(os.getcwd())
>>> 'origin' in r.remotes
False

Whereas looping over the names results in a match

>>> import os, pygit2
>>> r = pygit2.Repository(os.getcwd())
>>> 'origin' in [remote.name for remote in r.remotes]
True

This behavior seems unpythonic since remote.RemoteCollection implements __getitem__() and in doesn't match with a valid key in the collection.

If this change makes sense I can to try fix it when I have time, lmk!