##// END OF EJS Templates
typing: add type hints to global variables in mercurial/pycompat.py...
Matt Harbison -
r50696:9cd32750 default
parent child Browse files
Show More
@@ -28,6 +28,10 b' import sys'
28 import tempfile
28 import tempfile
29 import xmlrpc.client as xmlrpclib
29 import xmlrpc.client as xmlrpclib
30
30
31 from typing import (
32 List,
33 Optional,
34 )
31
35
32 ispy3 = sys.version_info[0] >= 3
36 ispy3 = sys.version_info[0] >= 3
33 ispypy = '__pypy__' in sys.builtin_module_names
37 ispypy = '__pypy__' in sys.builtin_module_names
@@ -94,21 +98,17 b" if os.name == r'nt':"
94
98
95 fsencode = os.fsencode
99 fsencode = os.fsencode
96 fsdecode = os.fsdecode
100 fsdecode = os.fsdecode
97 oscurdir = os.curdir.encode('ascii')
101 oscurdir: bytes = os.curdir.encode('ascii')
98 oslinesep = os.linesep.encode('ascii')
102 oslinesep: bytes = os.linesep.encode('ascii')
99 osname = os.name.encode('ascii')
103 osname: bytes = os.name.encode('ascii')
100 ospathsep = os.pathsep.encode('ascii')
104 ospathsep: bytes = os.pathsep.encode('ascii')
101 ospardir = os.pardir.encode('ascii')
105 ospardir: bytes = os.pardir.encode('ascii')
102 ossep = os.sep.encode('ascii')
106 ossep: bytes = os.sep.encode('ascii')
103 osaltsep = os.altsep
107 osaltsep: Optional[bytes] = os.altsep.encode('ascii') if os.altsep else None
104 if osaltsep:
108 osdevnull: bytes = os.devnull.encode('ascii')
105 osaltsep = osaltsep.encode('ascii')
106 osdevnull = os.devnull.encode('ascii')
107
109
108 sysplatform = sys.platform.encode('ascii')
110 sysplatform: bytes = sys.platform.encode('ascii')
109 sysexecutable = sys.executable
111 sysexecutable: bytes = os.fsencode(sys.executable) if sys.executable else b''
110 if sysexecutable:
111 sysexecutable = os.fsencode(sysexecutable)
112
112
113
113
114 def maplist(*args):
114 def maplist(*args):
@@ -143,6 +143,7 b" if getattr(sys, 'argv', None) is not Non"
143 # (this is how Python 2 worked). To get that, we encode with the mbcs
143 # (this is how Python 2 worked). To get that, we encode with the mbcs
144 # encoding, which will pass CP_ACP to the underlying Windows API to
144 # encoding, which will pass CP_ACP to the underlying Windows API to
145 # produce bytes.
145 # produce bytes.
146 sysargv: List[bytes] = []
146 if os.name == r'nt':
147 if os.name == r'nt':
147 sysargv = [a.encode("mbcs", "ignore") for a in sys.argv]
148 sysargv = [a.encode("mbcs", "ignore") for a in sys.argv]
148 else:
149 else:
@@ -377,12 +378,12 b' itervalues = lambda x: x.values()'
377
378
378 json_loads = json.loads
379 json_loads = json.loads
379
380
380 isjython = sysplatform.startswith(b'java')
381 isjython: bool = sysplatform.startswith(b'java')
381
382
382 isdarwin = sysplatform.startswith(b'darwin')
383 isdarwin: bool = sysplatform.startswith(b'darwin')
383 islinux = sysplatform.startswith(b'linux')
384 islinux: bool = sysplatform.startswith(b'linux')
384 isposix = osname == b'posix'
385 isposix: bool = osname == b'posix'
385 iswindows = osname == b'nt'
386 iswindows: bool = osname == b'nt'
386
387
387
388
388 def getoptb(args, shortlist, namelist):
389 def getoptb(args, shortlist, namelist):
General Comments 0
You need to be logged in to leave comments. Login now