# HG changeset patch # User Matt Harbison # Date 1671233235 18000 # Node ID ae93ada06454bb65b0c83c5839f9713d8f5acb99 # Parent 464fe8b8f4746dbe6ee759f6c791ca8fd4add07a typing: add type hints to the rest of the posix module These methods either don't have an analog in the windows module, or are aliased in the windows module from something else (like os.path.xxx). diff -r 464fe8b8f474 -r ae93ada06454 mercurial/posix.py --- a/mercurial/posix.py Fri Dec 16 18:14:54 2022 -0500 +++ b/mercurial/posix.py Fri Dec 16 18:27:15 2022 -0500 @@ -24,9 +24,11 @@ Iterable, Iterator, List, + Match, NoReturn, Optional, Sequence, + Tuple, Union, ) @@ -65,15 +67,15 @@ unlink = os.unlink rename = os.rename removedirs = os.removedirs -expandglobs = False +expandglobs: bool = False -umask = os.umask(0) +umask: int = os.umask(0) os.umask(umask) posixfile = open -def split(p): +def split(p: bytes) -> Tuple[bytes, bytes]: """Same as posixpath.split, but faster >>> import posixpath @@ -352,13 +354,13 @@ return False -def checkosfilename(path): +def checkosfilename(path: bytes) -> Optional[bytes]: """Check that the base-relative path is a valid filename on this platform. Returns None if the path is ok, or a UI string describing the problem.""" return None # on posix platforms, every path is ok -def getfsmountpoint(dirpath): +def getfsmountpoint(dirpath: bytes) -> Optional[bytes]: """Get the filesystem mount point from a directory (best-effort) Returns None if we are unsure. Raises OSError on ENOENT, EPERM, etc. @@ -410,7 +412,7 @@ # what normcase does to ASCII strings -normcasespec = encoding.normcasespecs.lower +normcasespec: int = encoding.normcasespecs.lower # fallback normcase function for non-ASCII strings normcasefallback = normcase @@ -518,7 +520,7 @@ return False -_needsshellquote = None +_needsshellquote: Optional[Match[bytes]] = None def shellquote(s: bytes) -> bytes: @@ -647,7 +649,7 @@ return os.spawnvp(os.P_NOWAIT | getattr(os, 'P_DETACH', 0), args[0], args) -def gethgcmd(): +def gethgcmd(): # TODO: convert to bytes, like on Windows? return sys.argv[:1]