Show More
@@ -17,12 +17,15 b' import sys' | |||
|
17 | 17 | import winreg # pytype: disable=import-error |
|
18 | 18 | |
|
19 | 19 | from typing import ( |
|
20 | AnyStr, | |
|
20 | 21 | BinaryIO, |
|
21 | 22 | Iterable, |
|
22 | 23 | Iterator, |
|
23 | 24 | List, |
|
25 | Mapping, | |
|
24 | 26 | NoReturn, |
|
25 | 27 | Optional, |
|
28 | Pattern, | |
|
26 | 29 | Sequence, |
|
27 | 30 | Union, |
|
28 | 31 | ) |
@@ -56,7 +59,7 b' split = os.path.split' | |||
|
56 | 59 | testpid = win32.testpid |
|
57 | 60 | unlink = win32.unlink |
|
58 | 61 | |
|
59 | umask = 0o022 | |
|
62 | umask: int = 0o022 | |
|
60 | 63 | |
|
61 | 64 | |
|
62 | 65 | class mixedfilemodewrapper: |
@@ -317,7 +320,7 b' def localpath(path: bytes) -> bytes:' | |||
|
317 | 320 | return path.replace(b'/', b'\\') |
|
318 | 321 | |
|
319 | 322 | |
|
320 | def normpath(path): | |
|
323 | def normpath(path: bytes) -> bytes: | |
|
321 | 324 | return pconvert(os.path.normpath(path)) |
|
322 | 325 | |
|
323 | 326 | |
@@ -325,11 +328,12 b' def normcase(path: bytes) -> bytes:' | |||
|
325 | 328 | return encoding.upper(path) # NTFS compares via upper() |
|
326 | 329 | |
|
327 | 330 | |
|
328 | DRIVE_RE_B = re.compile(b'^[a-z]:') | |
|
329 | DRIVE_RE_S = re.compile('^[a-z]:') | |
|
331 | DRIVE_RE_B: Pattern[bytes] = re.compile(b'^[a-z]:') | |
|
332 | DRIVE_RE_S: Pattern[str] = re.compile('^[a-z]:') | |
|
330 | 333 | |
|
331 | 334 | |
|
332 | def abspath(path): | |
|
335 | # TODO: why is this accepting str? | |
|
336 | def abspath(path: AnyStr) -> AnyStr: | |
|
333 | 337 | abs_path = os.path.abspath(path) # re-exports |
|
334 | 338 | # Python on Windows is inconsistent regarding the capitalization of drive |
|
335 | 339 | # letter and this cause issue with various path comparison along the way. |
@@ -345,15 +349,15 b' def abspath(path):' | |||
|
345 | 349 | |
|
346 | 350 | |
|
347 | 351 | # see posix.py for definitions |
|
348 | normcasespec = encoding.normcasespecs.upper | |
|
352 | normcasespec: int = encoding.normcasespecs.upper | |
|
349 | 353 | normcasefallback = encoding.upperfallback |
|
350 | 354 | |
|
351 | 355 | |
|
352 | def samestat(s1, s2): | |
|
356 | def samestat(s1: os.stat_result, s2: os.stat_result) -> bool: | |
|
353 | 357 | return False |
|
354 | 358 | |
|
355 | 359 | |
|
356 | def shelltocmdexe(path, env): | |
|
360 | def shelltocmdexe(path: bytes, env: Mapping[bytes, bytes]) -> bytes: | |
|
357 | 361 | r"""Convert shell variables in the form $var and ${var} inside ``path`` |
|
358 | 362 | to %var% form. Existing Windows style variables are left unchanged. |
|
359 | 363 | |
@@ -478,7 +482,7 b' def shelltocmdexe(path, env):' | |||
|
478 | 482 | # the number of backslashes that precede double quotes and add another |
|
479 | 483 | # backslash before every double quote (being careful with the double |
|
480 | 484 | # quote we've appended to the end) |
|
481 | _quotere = None | |
|
485 | _quotere: Optional[Pattern[bytes]] = None | |
|
482 | 486 | _needsshellquote = None |
|
483 | 487 | |
|
484 | 488 | |
@@ -512,7 +516,7 b' def shellquote(s: bytes) -> bytes:' | |||
|
512 | 516 | return b'"%s"' % _quotere.sub(br'\1\1\\\2', s) |
|
513 | 517 | |
|
514 | 518 | |
|
515 | def _unquote(s): | |
|
519 | def _unquote(s: bytes) -> bytes: | |
|
516 | 520 | if s.startswith(b'"') and s.endswith(b'"'): |
|
517 | 521 | return s[1:-1] |
|
518 | 522 | return s |
@@ -609,7 +613,7 b' def groupname(gid: Optional[int] = None)' | |||
|
609 | 613 | return None |
|
610 | 614 | |
|
611 | 615 | |
|
612 | def readlink(pathname): | |
|
616 | def readlink(pathname: bytes) -> bytes: | |
|
613 | 617 | path = pycompat.fsdecode(pathname) |
|
614 | 618 | try: |
|
615 | 619 | link = os.readlink(path) |
@@ -622,7 +626,7 b' def readlink(pathname):' | |||
|
622 | 626 | return pycompat.fsencode(link) |
|
623 | 627 | |
|
624 | 628 | |
|
625 | def removedirs(name): | |
|
629 | def removedirs(name: bytes) -> None: | |
|
626 | 630 | """special version of os.removedirs that does not remove symlinked |
|
627 | 631 | directories or junction points if they actually contain files""" |
|
628 | 632 | if listdir(name): |
@@ -641,7 +645,7 b' def removedirs(name):' | |||
|
641 | 645 | head, tail = os.path.split(head) |
|
642 | 646 | |
|
643 | 647 | |
|
644 | def rename(src, dst): | |
|
648 | def rename(src: bytes, dst: bytes) -> None: | |
|
645 | 649 | '''atomically rename file src to dst, replacing dst if it exists''' |
|
646 | 650 | try: |
|
647 | 651 | os.rename(src, dst) |
@@ -650,7 +654,7 b' def rename(src, dst):' | |||
|
650 | 654 | os.rename(src, dst) |
|
651 | 655 | |
|
652 | 656 | |
|
653 | def gethgcmd(): | |
|
657 | def gethgcmd() -> List[bytes]: | |
|
654 | 658 | return [encoding.strtolocal(arg) for arg in [sys.executable] + sys.argv[:1]] |
|
655 | 659 | |
|
656 | 660 | |
@@ -708,7 +712,7 b' def lookupreg(' | |||
|
708 | 712 | pass |
|
709 | 713 | |
|
710 | 714 | |
|
711 | expandglobs = True | |
|
715 | expandglobs: bool = True | |
|
712 | 716 | |
|
713 | 717 | |
|
714 | 718 | def statislink(st: Optional[os.stat_result]) -> bool: |
@@ -721,7 +725,7 b' def statisexec(st: Optional[os.stat_resu' | |||
|
721 | 725 | return False |
|
722 | 726 | |
|
723 | 727 | |
|
724 | def poll(fds): | |
|
728 | def poll(fds) -> List: | |
|
725 | 729 | # see posix.py for description |
|
726 | 730 | raise NotImplementedError() |
|
727 | 731 |
General Comments 0
You need to be logged in to leave comments.
Login now