windows: suppress pytype warnings for Windows imports and functions
authorMatt Harbison <matt_harbison@yahoo.com>
Fri, 22 Nov 2019 23:55:57 -0500
changeset 43788 fe73ec69350e
parent 43787 f3b23d5c15fd
child 43789 27c6d6f53d46
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
mercurial/pycompat.py
mercurial/scmwindows.py
mercurial/windows.py
--- a/mercurial/pycompat.py	Sat Nov 23 16:54:59 2019 -0800
+++ b/mercurial/pycompat.py	Fri Nov 22 23:55:57 2019 -0500
@@ -99,7 +99,7 @@
         # 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
--- a/mercurial/scmwindows.py	Sat Nov 23 16:54:59 2019 -0800
+++ b/mercurial/scmwindows.py	Fri Nov 22 23:55:57 2019 -0500
@@ -10,11 +10,12 @@
 )
 
 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'
--- a/mercurial/windows.py	Sat Nov 23 16:54:59 2019 -0800
+++ b/mercurial/windows.py	Fri Nov 22 23:55:57 2019 -0500
@@ -26,11 +26,12 @@
 )
 
 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 @@
     # 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):