# HG changeset patch # User Matt Harbison # Date 2019-11-23 04:55:57 # Node ID fe73ec69350ebeab493f5dbe17e036007b450abb # Parent f3b23d5c15fd09a779ba9cca020d7677a968f29b windows: suppress pytype warnings for Windows imports and functions This should allow the modules to not be excluded, and not generate complaints on non Windows platforms. Differential Revision: https://phab.mercurial-scm.org/D7510 diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py --- a/mercurial/pycompat.py +++ b/mercurial/pycompat.py @@ -99,7 +99,7 @@ if ispy3: # Otherwise non-ASCII filenames in existing repositories would be # corrupted. # This must be set once prior to any fsencode/fsdecode calls. - sys._enablelegacywindowsfsencoding() + sys._enablelegacywindowsfsencoding() # pytype: disable=module-attr fsencode = os.fsencode fsdecode = os.fsdecode diff --git a/mercurial/scmwindows.py b/mercurial/scmwindows.py --- a/mercurial/scmwindows.py +++ b/mercurial/scmwindows.py @@ -10,11 +10,12 @@ from . import ( ) try: - import _winreg as winreg + import _winreg as winreg # pytype: disable=import-error winreg.CloseKey except ImportError: - import winreg + # py2 only + import winreg # pytype: disable=import-error # MS-DOS 'more' is the only pager available by default on Windows. fallbackpager = b'more' diff --git a/mercurial/windows.py b/mercurial/windows.py --- a/mercurial/windows.py +++ b/mercurial/windows.py @@ -26,11 +26,12 @@ from . import ( ) try: - import _winreg as winreg + import _winreg as winreg # pytype: disable=import-error winreg.CloseKey except ImportError: - import winreg + # py2 only + import winreg # pytype: disable=import-error osutil = policy.importmod('osutil') @@ -282,7 +283,7 @@ def setbinary(fd): # fileno(), usually set to -1. fno = getattr(fd, 'fileno', None) if fno is not None and fno() >= 0: - msvcrt.setmode(fno(), os.O_BINARY) + msvcrt.setmode(fno(), os.O_BINARY) # pytype: disable=module-attr def pconvert(path):