Skip to content

Commit 526e592

Browse files
author
Guido van Rossum
committed
Need more type annotations now semanal can assign types.
1 parent e7e06a8 commit 526e592

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

test-data/stdlib-samples/3.2/posixpath.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ def split(p: AnyStr) -> Tuple[AnyStr, AnyStr]:
111111

112112
def splitext(p: AnyStr) -> Tuple[AnyStr, AnyStr]:
113113
if isinstance(p, bytes):
114-
sep = b'/'
115-
extsep = b'.'
114+
sep = b'/' # type: AnyStr
115+
extsep = b'.' # type: AnyStr
116116
else:
117117
sep = '/'
118118
extsep = '.'
@@ -240,7 +240,7 @@ def expanduser(path: AnyStr) -> AnyStr:
240240
"""Expand ~ and ~user constructions. If user or $HOME is unknown,
241241
do nothing."""
242242
if isinstance(path, bytes):
243-
tilde = b'~'
243+
tilde = b'~' # type: AnyStr
244244
else:
245245
tilde = '~'
246246
if not path.startswith(tilde):
@@ -268,7 +268,7 @@ def expanduser(path: AnyStr) -> AnyStr:
268268
userhome = pwent.pw_dir
269269
if isinstance(path, bytes):
270270
userhome = os.fsencode(userhome)
271-
root = b'/'
271+
root = b'/' # type: AnyStr
272272
else:
273273
root = '/'
274274
userhome = userhome.rstrip(root)
@@ -293,8 +293,8 @@ def expandvars(path: AnyStr) -> AnyStr:
293293
import re
294294
_varprogb = re.compile(br'\$(\w+|\{[^}]*\})', re.ASCII)
295295
search = _varprogb.search
296-
start = b'{'
297-
end = b'}'
296+
start = b'{' # type: AnyStr
297+
end = b'}' # type: AnyStr
298298
else:
299299
if '$' not in path:
300300
return path
@@ -337,10 +337,10 @@ def expandvars(path: AnyStr) -> AnyStr:
337337
def normpath(path: AnyStr) -> AnyStr:
338338
"""Normalize path, eliminating double slashes, etc."""
339339
if isinstance(path, bytes):
340-
sep = b'/'
341-
empty = b''
342-
dot = b'.'
343-
dotdot = b'..'
340+
sep = b'/' # type: AnyStr
341+
empty = b'' # type: AnyStr
342+
dot = b'.' # type: AnyStr
343+
dotdot = b'..' # type: AnyStr
344344
else:
345345
sep = '/'
346346
empty = ''
@@ -389,8 +389,8 @@ def realpath(filename: AnyStr) -> AnyStr:
389389
"""Return the canonical path of the specified filename, eliminating any
390390
symbolic links encountered in the path."""
391391
if isinstance(filename, bytes):
392-
sep = b'/'
393-
empty = b''
392+
sep = b'/' # type: AnyStr
393+
empty = b'' # type: AnyStr
394394
else:
395395
sep = '/'
396396
empty = ''
@@ -443,9 +443,9 @@ def relpath(path: AnyStr, start: AnyStr = None) -> AnyStr:
443443
raise ValueError("no path specified")
444444

445445
if isinstance(path, bytes):
446-
curdir = b'.'
447-
sep = b'/'
448-
pardir = b'..'
446+
curdir = b'.' # type: AnyStr
447+
sep = b'/' # type: AnyStr
448+
pardir = b'..' # type: AnyStr
449449
else:
450450
curdir = '.'
451451
sep = '/'

0 commit comments

Comments
 (0)