# HG changeset patch # User Matt Harbison # Date 1673028290 18000 # Node ID de9ffb82ef4dd3950b8e102e8636fa69f9d2edef # Parent 139f713010ea98aa6834e41c57eb3a9bfc9a3c2e 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). diff -r 139f713010ea -r de9ffb82ef4d hgext/convert/bzr.py --- a/hgext/convert/bzr.py Thu Jan 05 00:09:48 2023 -0500 +++ b/hgext/convert/bzr.py Fri Jan 06 13:04:50 2023 -0500 @@ -31,11 +31,14 @@ try: # bazaar imports + # pytype: disable=import-error import breezy.bzr.bzrdir import breezy.errors import breezy.revision import breezy.revisionspec + # pytype: enable=import-error + bzrdir = breezy.bzr.bzrdir errors = breezy.errors revision = breezy.revision diff -r 139f713010ea -r de9ffb82ef4d hgext/convert/subversion.py --- a/hgext/convert/subversion.py Thu Jan 05 00:09:48 2023 -0500 +++ b/hgext/convert/subversion.py Fri Jan 06 13:04:50 2023 -0500 @@ -47,11 +47,14 @@ # these bindings. try: + # pytype: disable=import-error import svn import svn.client import svn.core import svn.ra import svn.delta + + # pytype: enable=import-error from . import transport import warnings diff -r 139f713010ea -r de9ffb82ef4d hgext/convert/transport.py --- a/hgext/convert/transport.py Thu Jan 05 00:09:48 2023 -0500 +++ b/hgext/convert/transport.py Fri Jan 06 13:04:50 2023 -0500 @@ -17,10 +17,13 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, see . +# pytype: disable=import-error import svn.client import svn.core import svn.ra +# pytype: enable=import-error + Pool = svn.core.Pool SubversionException = svn.core.SubversionException @@ -37,7 +40,7 @@ def _create_auth_baton(pool): """Create a Subversion authentication baton.""" - import svn.client + import svn.client # pytype: disable=import-error # Give the client context baton a suite of authentication # providers.h diff -r 139f713010ea -r de9ffb82ef4d hgext/git/gitutil.py --- a/hgext/git/gitutil.py Thu Jan 05 00:09:48 2023 -0500 +++ b/hgext/git/gitutil.py Fri Jan 06 13:04:50 2023 -0500 @@ -9,7 +9,7 @@ global pygit2_module if pygit2_module is None: try: - import pygit2 as pygit2_module + import pygit2 as pygit2_module # pytype: disable=import-error pygit2_module.InvalidSpecError except (ImportError, AttributeError): diff -r 139f713010ea -r de9ffb82ef4d hgext/phabricator.py --- a/hgext/phabricator.py Thu Jan 05 00:09:48 2023 -0500 +++ b/hgext/phabricator.py Fri Jan 06 13:04:50 2023 -0500 @@ -286,9 +286,12 @@ import hgdemandimport with hgdemandimport.deactivated(): + # pytype: disable=import-error import vcr as vcrmod import vcr.stubs as stubs + # pytype: enable=import-error + vcr = vcrmod.VCR( serializer='json', before_record_request=sanitiserequest, diff -r 139f713010ea -r de9ffb82ef4d hgext/releasenotes.py --- a/hgext/releasenotes.py Thu Jan 05 00:09:48 2023 -0500 +++ b/hgext/releasenotes.py Fri Jan 06 13:04:50 2023 -0500 @@ -50,7 +50,7 @@ module="fuzzywuzzy.fuzz", ) - import fuzzywuzzy.fuzz as fuzz + import fuzzywuzzy.fuzz as fuzz # pytype: disable=import-error fuzz.token_set_ratio except ImportError: diff -r 139f713010ea -r de9ffb82ef4d hgext/sqlitestore.py --- a/hgext/sqlitestore.py Thu Jan 05 00:09:48 2023 -0500 +++ b/hgext/sqlitestore.py Fri Jan 06 13:04:50 2023 -0500 @@ -80,7 +80,7 @@ ) try: - from mercurial import zstd + from mercurial import zstd # pytype: disable=import-error zstd.__version__ except ImportError: