comparison hgext/git/gitutil.py @ 49849:de9ffb82ef4d

typing: suppress a bunch of potential import-error cases in extensions As flagged by pytype locally. Either the ImportError is locally handled, or the imported module was previously determined to be present by `hgave` (for the phabricator extension), or is handled by the `hgext.convert.subversion` module when imported (for the `hgext.convert.transport` module).
author Matt Harbison <matt_harbison@yahoo.com>
date Fri, 06 Jan 2023 13:04:50 -0500
parents 227124098e14
children f4733654f144
comparison
equal deleted inserted replaced
49848:139f713010ea 49849:de9ffb82ef4d
7 7
8 def get_pygit2(): 8 def get_pygit2():
9 global pygit2_module 9 global pygit2_module
10 if pygit2_module is None: 10 if pygit2_module is None:
11 try: 11 try:
12 import pygit2 as pygit2_module 12 import pygit2 as pygit2_module # pytype: disable=import-error
13 13
14 pygit2_module.InvalidSpecError 14 pygit2_module.InvalidSpecError
15 except (ImportError, AttributeError): 15 except (ImportError, AttributeError):
16 pass 16 pass
17 return pygit2_module 17 return pygit2_module