Fri, 16 Dec 2022 18:14:54 -0500 typing: add type hints to the platform `cachestat` classes
Matt Harbison <matt_harbison@yahoo.com> [Fri, 16 Dec 2022 18:14:54 -0500] rev 49815
typing: add type hints to the platform `cachestat` classes
Fri, 16 Dec 2022 14:24:02 -0500 util: fix the signature of observedbufferedinputpipe._fillbuffer()
Matt Harbison <matt_harbison@yahoo.com> [Fri, 16 Dec 2022 14:24:02 -0500] rev 49814
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.
Fri, 16 Dec 2022 14:15:09 -0500 tests: drop some obsolete py2 handling in util.py doctest
Matt Harbison <matt_harbison@yahoo.com> [Fri, 16 Dec 2022 14:15:09 -0500] rev 49813
tests: drop some obsolete py2 handling in util.py doctest Flagged by PyCharm while inspecting imports from the platform modules.
Fri, 16 Dec 2022 00:54:39 -0500 typing: add type hints to the common posix/windows platform functions
Matt Harbison <matt_harbison@yahoo.com> [Fri, 16 Dec 2022 00:54:39 -0500] rev 49812
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.
Thu, 15 Dec 2022 21:13:11 -0500 typing: add type hints to the posix platform module matching win32.py
Matt Harbison <matt_harbison@yahoo.com> [Thu, 15 Dec 2022 21:13:11 -0500] rev 49811
typing: add type hints to the posix platform module matching win32.py
Thu, 15 Dec 2022 18:02:55 -0500 typing: add type hints to mercurial/win32.py
Matt Harbison <matt_harbison@yahoo.com> [Thu, 15 Dec 2022 18:02:55 -0500] rev 49810
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.
Thu, 15 Dec 2022 15:46:25 -0500 windows: drop some py2 registry module importing
Matt Harbison <matt_harbison@yahoo.com> [Thu, 15 Dec 2022 15:46:25 -0500] rev 49809
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.
Thu, 15 Dec 2022 15:41:59 -0500 typing: add type hints to the platform specific scm modules
Matt Harbison <matt_harbison@yahoo.com> [Thu, 15 Dec 2022 15:41:59 -0500] rev 49808
typing: add type hints to the platform specific scm modules Surprisingly, pytype struggled to figure out the return types in the posix functions.
Thu, 15 Dec 2022 01:05:27 -0500 typing: add type hints to most mercurial/pycompat.py functions
Matt Harbison <matt_harbison@yahoo.com> [Thu, 15 Dec 2022 01:05:27 -0500] rev 49807
typing: add type hints to most mercurial/pycompat.py functions The `rapply` methods are left out because it's not `rapply(f, xs: _T0) -> _T0` as I first thought- it's used somewhere to walk a collection and convert between bytes and str. Also, the `open()` call is partially untyped because I'm not sure what its purpose is at this point- both the name and mode can be either bytes or str as it is currently constituted. It might make sense to assert that the file is being opened in binary mode (like `namedtempfile()`) and cast the result to `BinaryIO`, but that shouldn't be smuggled in with these other changes. The return is currently typed as `Any` because something suddenly got smarter and a few uses in util.py (like readfile()) suddenly think it returns `IO[str]` instead of `IO[bytes]` (BinaryIO), and it flags the type mismatch there.
Wed, 14 Dec 2022 22:27:22 -0500 statprof: don't pass str `sys.argv` to a function expecting bytes
Matt Harbison <matt_harbison@yahoo.com> [Wed, 14 Dec 2022 22:27:22 -0500] rev 49806
statprof: don't pass str `sys.argv` to a function expecting bytes Found by typing the global functions in mercurial.pycompat.
(0) -30000 -10000 -3000 -1000 -300 -100 -10 +10 +100 +300 +1000 tip