Documentation for the get() method for SubmoduleCollection indicates that the function returns None if the submodule is not found.
However, the following sample script throws <class 'ValueError'> submodule 'second' has not been added yet.
import tempfile
from pygit2 import init_repository
# This should print "Success"
with tempfile.TemporaryDirectory() as prefix:
first_prefix = f'{prefix}/first'
second_prefix = f'{first_prefix}/second'
first = init_repository(first_prefix)
second = init_repository(second_prefix)
try:
assert first.submodules.get('second') is None
print('Success')
except Exception as e:
print(type(e), e)
By looking at the get() function code, it catches KeyError but not ValueError. Is that an expected but undocumented behavior? Or should the function also catch ValueErrors?