Wed, 14 Dec 2022 01:38:52 -0500 pycompat: explicitly prefix builtin attr usage with `builtins.`
Matt Harbison <matt_harbison@yahoo.com> [Wed, 14 Dec 2022 01:38:52 -0500] rev 49802
pycompat: explicitly prefix builtin attr usage with `builtins.` It doesn't seem like this would fix any bug, because the wrapped functions that take bytes instead of str are defined after these calls. But PyCharm was flagging the second and third uses, saying "Type 'str' doesn't have expected attribute 'decode'". It wasn't flagging the first, but I changed it for consistency.
Wed, 14 Dec 2022 01:32:03 -0500 typing: add type hints to global variables in mercurial/pycompat.py
Matt Harbison <matt_harbison@yahoo.com> [Wed, 14 Dec 2022 01:32:03 -0500] rev 49801
typing: add type hints to global variables in mercurial/pycompat.py The way `osaltsep` and `sysexecutable` were defined, pytype determined them to be `Union[bytes, str]`. This was a problem because that cascaded to all of the callers, and also because it couldn't be annotated as bytes on the initial assignment. Therefore, we use a ternary operator. The documentation says that `sys.executable` can either be None or an empty string if the value couldn't be determined. We opt for an empty string here because there are places that blindly pass it to `os.path.xxx()` functions, which crash if given None. Other places test `if pycompat.sysexecutable`, so empty string works for both.
Tue, 13 Dec 2022 16:48:47 -0500 windows: drop an unused method
Matt Harbison <matt_harbison@yahoo.com> [Tue, 13 Dec 2022 16:48:47 -0500] rev 49800
windows: drop an unused method The only caller was removed in 563eb25e079b.
Mon, 12 Dec 2022 14:10:12 -0500 typing: add type hints to the prompt methods in mercurial/ui.py
Matt Harbison <matt_harbison@yahoo.com> [Mon, 12 Dec 2022 14:10:12 -0500] rev 49799
typing: add type hints to the prompt methods in mercurial/ui.py The @overloads allow for the callers that pass a non-None `default` to not have to worry about handling a None return to appease pytype.
Mon, 12 Dec 2022 14:17:05 -0500 ui: split the `default` arg out of **kwargs for the internal prompt method
Matt Harbison <matt_harbison@yahoo.com> [Mon, 12 Dec 2022 14:17:05 -0500] rev 49798
ui: split the `default` arg out of **kwargs for the internal prompt method This arg was required anyway, based on how it was accessed. Having it separate allows it to be typed though, and this will simplify things for the callers- if a non-None `default` is passed, the return can never be None. That can be expressed with `@overload` when the arg can be typed, but that's not possible when it is rolled up in **kwargs. The default value is simply copied from the public `prompt()` above it.
Sun, 11 Dec 2022 00:10:56 -0500 typing: add trivial type hints to mercurial/ui.py
Matt Harbison <matt_harbison@yahoo.com> [Sun, 11 Dec 2022 00:10:56 -0500] rev 49797
typing: add trivial type hints to mercurial/ui.py There's not really a pattern here; it's mostly obvious return types and in a few cases, obvious parameter types. Some other "obvious" functions are left out because of quirks in how the return value for the various config() functions are inferred cause pytype to complain.
Sat, 10 Dec 2022 14:57:42 -0500 doc: don't pass str to ui methods in check-seclevel.py
Matt Harbison <matt_harbison@yahoo.com> [Sat, 10 Dec 2022 14:57:42 -0500] rev 49796
doc: don't pass str to ui methods in check-seclevel.py
Sat, 10 Dec 2022 14:44:46 -0500 typing: add type hints related to message output in mercurial/ui.py
Matt Harbison <matt_harbison@yahoo.com> [Sat, 10 Dec 2022 14:44:46 -0500] rev 49795
typing: add type hints related to message output in mercurial/ui.py This will shake loose some bytes vs str issues in the doc checker.
Sat, 10 Dec 2022 00:22:13 -0500 typing: add type hints related to progress bars in mercurial/ui.py
Matt Harbison <matt_harbison@yahoo.com> [Sat, 10 Dec 2022 00:22:13 -0500] rev 49794
typing: add type hints related to progress bars in mercurial/ui.py Pretty low hanging fruit while trying to deal with other more complicated parts of this module.
Fri, 25 Nov 2022 18:39:47 -0500 pytype: stop excluding mercurial/ui.py
Matt Harbison <matt_harbison@yahoo.com> [Fri, 25 Nov 2022 18:39:47 -0500] rev 49793
pytype: stop excluding mercurial/ui.py ui.extractchoices() is perhaps making assumptions that it shouldn't about the pattern always matching, but presumably we have test coverage for that. PyCharm flags the updated classes with a warning "Class xxx must implement all abstract methods", and suggests adding `abc.ABC` to the superclasses. I'm not sure why, unless it doesn't recognize the `__getattr__()` delegation pattern. Additionally, we can't unconditionally subclass `typing.BinaryIO` because that defeats the `__getattr__` delegation to the wrapped object at runtime. Instead, it has to only subclass during the type checking phase[1]. In any event, this fixes: File "/mnt/c/Users/Matt/hg/mercurial/ui.py", line 1518, in _runpager: Function subprocess.Popen.__new__ was called with the wrong arguments [wrong-arg-types] Expected: (cls, args, bufsize, executable, stdin, stdout: Optional[Union[IO, int]] = ..., ...) Actually passed: (cls, args, bufsize, stdin, stdout: Union[mercurial.utils.procutil.WriteAllWrapper, mercurial.windows.winstdout], ...) File "/mnt/c/Users/Matt/hg/mercurial/ui.py", line 1798, in extractchoices: No attribute 'group' on None [attribute-error] In Optional[Match[bytes]] File "/mnt/c/Users/Matt/hg/mercurial/ui.py", line 1799, in extractchoices: No attribute 'group' on None [attribute-error] In Optional[Match[bytes]] [1] https://stackoverflow.com/q/71365594
(0) -30000 -10000 -3000 -1000 -300 -100 -10 +10 +100 +300 +1000 tip