##// END OF EJS Templates
typing: add type hints to the platform specific scm modules...
Matt Harbison -
r50703:7a414342 default
parent child Browse files
Show More
@@ -4,6 +4,11 b' import fcntl'
4 4 import os
5 5 import sys
6 6
7 from typing import (
8 List,
9 Tuple,
10 )
11
7 12 from .pycompat import getattr
8 13 from . import (
9 14 encoding,
@@ -11,6 +16,9 b' from . import ('
11 16 util,
12 17 )
13 18
19 if pycompat.TYPE_CHECKING:
20 from . import ui as uimod
21
14 22 # BSD 'more' escapes ANSI color sequences by default. This can be disabled by
15 23 # $MORE variable, but there's no compatible option with Linux 'more'. Given
16 24 # OS X is widely used and most modern Unix systems would have 'less', setting
@@ -18,7 +26,7 b' from . import ('
18 26 fallbackpager = b'less'
19 27
20 28
21 def _rcfiles(path):
29 def _rcfiles(path: bytes) -> List[bytes]:
22 30 rcs = [os.path.join(path, b'hgrc')]
23 31 rcdir = os.path.join(path, b'hgrc.d')
24 32 try:
@@ -34,7 +42,7 b' def _rcfiles(path):'
34 42 return rcs
35 43
36 44
37 def systemrcpath():
45 def systemrcpath() -> List[bytes]:
38 46 path = []
39 47 if pycompat.sysplatform == b'plan9':
40 48 root = b'lib/mercurial'
@@ -49,7 +57,7 b' def systemrcpath():'
49 57 return path
50 58
51 59
52 def userrcpath():
60 def userrcpath() -> List[bytes]:
53 61 if pycompat.sysplatform == b'plan9':
54 62 return [encoding.environ[b'home'] + b'/lib/hgrc']
55 63 elif pycompat.isdarwin:
@@ -65,7 +73,7 b' def userrcpath():'
65 73 ]
66 74
67 75
68 def termsize(ui):
76 def termsize(ui: "uimod.ui") -> Tuple[int, int]:
69 77 try:
70 78 import termios
71 79
@@ -1,5 +1,10 b''
1 1 import os
2 2
3 from typing import (
4 List,
5 Tuple,
6 )
7
3 8 from . import (
4 9 encoding,
5 10 pycompat,
@@ -7,6 +12,9 b' from . import ('
7 12 win32,
8 13 )
9 14
15 if pycompat.TYPE_CHECKING:
16 from . import ui as uimod
17
10 18 try:
11 19 import _winreg as winreg # pytype: disable=import-error
12 20
@@ -19,7 +27,7 b' except ImportError:'
19 27 fallbackpager = b'more'
20 28
21 29
22 def systemrcpath():
30 def systemrcpath() -> List[bytes]:
23 31 '''return default os-specific hgrc search path'''
24 32 rcpath = []
25 33 filename = win32.executablepath()
@@ -27,7 +35,7 b' def systemrcpath():'
27 35 progrc = os.path.join(os.path.dirname(filename), b'mercurial.ini')
28 36 rcpath.append(progrc)
29 37
30 def _processdir(progrcd):
38 def _processdir(progrcd: bytes) -> None:
31 39 if os.path.isdir(progrcd):
32 40 for f, kind in sorted(util.listdir(progrcd)):
33 41 if f.endswith(b'.rc'):
@@ -68,7 +76,7 b' def systemrcpath():'
68 76 return rcpath
69 77
70 78
71 def userrcpath():
79 def userrcpath() -> List[bytes]:
72 80 '''return os-specific hgrc search path to the user dir'''
73 81 home = _legacy_expanduser(b'~')
74 82 path = [os.path.join(home, b'mercurial.ini'), os.path.join(home, b'.hgrc')]
@@ -79,7 +87,7 b' def userrcpath():'
79 87 return path
80 88
81 89
82 def _legacy_expanduser(path):
90 def _legacy_expanduser(path: bytes) -> bytes:
83 91 """Expand ~ and ~user constructs in the pre 3.8 style"""
84 92
85 93 # Python 3.8+ changed the expansion of '~' from HOME to USERPROFILE. See
@@ -111,5 +119,5 b' def _legacy_expanduser(path):'
111 119 return userhome + path[i:]
112 120
113 121
114 def termsize(ui):
122 def termsize(ui: "uimod.ui") -> Tuple[int, int]:
115 123 return win32.termsize()
General Comments 0
You need to be logged in to leave comments. Login now