Mercurial > public > mercurial-scm > hg-stable
diff mercurial/scmposix.py @ 49903:7a4143428db7
typing: add type hints to the platform specific scm modules
Surprisingly, pytype struggled to figure out the return types in the posix
functions.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Thu, 15 Dec 2022 15:41:59 -0500 |
parents | a87338fe8cfa |
children | 18c8c18993f0 |
line wrap: on
line diff
--- a/mercurial/scmposix.py Thu Dec 15 01:05:27 2022 -0500 +++ b/mercurial/scmposix.py Thu Dec 15 15:41:59 2022 -0500 @@ -4,6 +4,11 @@ import os import sys +from typing import ( + List, + Tuple, +) + from .pycompat import getattr from . import ( encoding, @@ -11,6 +16,9 @@ util, ) +if pycompat.TYPE_CHECKING: + from . import ui as uimod + # BSD 'more' escapes ANSI color sequences by default. This can be disabled by # $MORE variable, but there's no compatible option with Linux 'more'. Given # OS X is widely used and most modern Unix systems would have 'less', setting @@ -18,7 +26,7 @@ fallbackpager = b'less' -def _rcfiles(path): +def _rcfiles(path: bytes) -> List[bytes]: rcs = [os.path.join(path, b'hgrc')] rcdir = os.path.join(path, b'hgrc.d') try: @@ -34,7 +42,7 @@ return rcs -def systemrcpath(): +def systemrcpath() -> List[bytes]: path = [] if pycompat.sysplatform == b'plan9': root = b'lib/mercurial' @@ -49,7 +57,7 @@ return path -def userrcpath(): +def userrcpath() -> List[bytes]: if pycompat.sysplatform == b'plan9': return [encoding.environ[b'home'] + b'/lib/hgrc'] elif pycompat.isdarwin: @@ -65,7 +73,7 @@ ] -def termsize(ui): +def termsize(ui: "uimod.ui") -> Tuple[int, int]: try: import termios