Matt Harbison <matt_harbison@yahoo.com> [Fri, 16 Dec 2022 22:07:02 -0500] rev 49912
typing: add trivial type hints to rest of the windows platform module
Skipping the file wrappers for now because there's interplay with C code, and
making them subclass `typing.BinaryIO_Proxy` confuses PyCharm a bit.
Matt Harbison <matt_harbison@yahoo.com> [Fri, 16 Dec 2022 18:27:15 -0500] rev 49911
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).
Matt Harbison <matt_harbison@yahoo.com> [Fri, 16 Dec 2022 18:14:54 -0500] rev 49910
typing: add type hints to the platform `cachestat` classes
Matt Harbison <matt_harbison@yahoo.com> [Fri, 16 Dec 2022 14:24:02 -0500] rev 49909
util: fix the signature of observedbufferedinputpipe._fillbuffer()
Flagged by PyCharm, since it didn't match the signature of the method being
overridden. The default value in the superclass is also `_chunksize`, and I
suspect that the amount read from `osread` should be limited to what is passed
in. Only one caller (`bufferedinputpipe.unbufferedread()`) passes this
argument, and it passes the max of `_chunksize` and whatever it was passed.
Matt Harbison <matt_harbison@yahoo.com> [Fri, 16 Dec 2022 14:15:09 -0500] rev 49908
tests: drop some obsolete py2 handling in util.py doctest
Flagged by PyCharm while inspecting imports from the platform modules.
Matt Harbison <matt_harbison@yahoo.com> [Fri, 16 Dec 2022 00:54:39 -0500] rev 49907
typing: add type hints to the common posix/windows platform functions
These are done in sync because some platforms have empty implementations, and it
isn't obvious what the types should be without examining the other. We want the
types aligned, so @overload definitions that differ aren't generated. The only
differences here are the few methods that unconditionally raise an error are
marked as `NoReturn`, which doesn't seem to bother pytype.
A couple of the posix module functions needed to be updated with a modern
ternary operator, because pytype seems to want to use the type of the second
object in the old `return x and y` style.
Matt Harbison <matt_harbison@yahoo.com> [Thu, 15 Dec 2022 21:13:11 -0500] rev 49906
typing: add type hints to the posix platform module matching win32.py
Matt Harbison <matt_harbison@yahoo.com> [Thu, 15 Dec 2022 18:02:55 -0500] rev 49905
typing: add type hints to mercurial/win32.py
These are the low level functions that are imported by the mercurial.windows
module, which is in turn imported by mercurial.utils as the platform module.
Pretty straightforward, but pytype inferred very little of it, likely because of
the heavy ctypes usage. It also seems to trigger a pytype bug in procutil, now
that it has an idea of the underlying function type, so disable that warning to
maintain a working test.
Matt Harbison <matt_harbison@yahoo.com> [Thu, 15 Dec 2022 15:46:25 -0500] rev 49904
windows: drop some py2 registry module importing
The comment was actually backwards- `winreg` is importable on py3, and is
already imported by mercurial/windows.py.
Matt Harbison <matt_harbison@yahoo.com> [Thu, 15 Dec 2022 15:41:59 -0500] rev 49903
typing: add type hints to the platform specific scm modules
Surprisingly, pytype struggled to figure out the return types in the posix
functions.