Tue, 23 Jul 2024 19:05:26 -0400 linelog: correct the default value of `annotateresult.lines`
Matt Harbison <matt_harbison@yahoo.com> [Tue, 23 Jul 2024 19:05:26 -0400] rev 51727
linelog: correct the default value of `annotateresult.lines` This was flagged by pytype once it was tricked into using the standard `attr` package instead of the vendored copy.
Tue, 23 Jul 2024 19:01:16 -0400 phabricator: correct the default value of `phabhunk.corpus`
Matt Harbison <matt_harbison@yahoo.com> [Tue, 23 Jul 2024 19:01:16 -0400] rev 51726
phabricator: correct the default value of `phabhunk.corpus` There's only one caller to this constructor (which does provide this argument), and no direct assignments, so there's no runtime bug here. However, when pytype is tricked into using the standard `attr` package instead of the vendored version, it flags this because bytes is passed to the one constructor invocation. Tricking pytype into using the standard package will generate many more type hints, noteably around `@attr.s` decorated things.
Mon, 22 Jul 2024 18:20:29 +0200 rust-changelog: accessing the index
Georges Racinet <georges.racinet@cloudcrane.io> [Mon, 22 Jul 2024 18:20:29 +0200] rev 51725
rust-changelog: accessing the index The `Index` object is currently the one providing all DAG related algorithms, starting with simple ancestors iteration up to more advanced ones (ranges, common ancestors…). From pure Rust code, there was no way to access the changelog index for a given `Repository`, probably because `rhg` does not use any such algorithm yet.
Sat, 20 Jul 2024 17:03:30 -0400 typing: add type hints to `mercurial.policy`
Matt Harbison <matt_harbison@yahoo.com> [Sat, 20 Jul 2024 17:03:30 -0400] rev 51724
typing: add type hints to `mercurial.policy` Mostly trivial, but this seems like the logical module to use to inject the hints from `cext`, `pure`, etc, given that this file has the fallback policy. This is a first step. There doesn't appear to be a predefined type for a module in py3.7, so those are omitted for now.
Sat, 20 Jul 2024 01:55:09 -0400 cext: correct the argument handling of `b85encode()`
Matt Harbison <matt_harbison@yahoo.com> [Sat, 20 Jul 2024 01:55:09 -0400] rev 51723
cext: correct the argument handling of `b85encode()` The type stub indicated that this argument is `Optional`, which implies None is allowed. I don't see in the documentation where that's the case for `i`[1], and trying it in `hg debugshell` resulted in the method failing with a TypeError. I guess it was typed as an `int` argument because the `p` format unit wasn't added until Python 3.3[2]. In any event, 2 clients in core (`pvec` and `obsolete`) call this with no argument supplied, and `mdiff` calls it with True. So I guess we've avoided the None arg case, and when no arg is supplied, it defaults to the 0 initialization of the `pad` variable in C. Since the `p` format unit accepts both `int` and None, as well as `bool`, I'm not bothering to bump the module version- this code is more permissive than it was, in addition to being more correct. Interestingly, when I first imported the `cext` and `pure` methods in the same manner as the previous commit, it dropped the `Optional` part of the argument type when generating `util.pyi`. No idea why. [1] https://docs.python.org/3/c-api/arg.html#numbers [2] https://docs.python.org/3/c-api/arg.html#other-objects
Fri, 19 Jul 2024 20:09:48 -0400 typing: add type hints to the `charencode` module
Matt Harbison <matt_harbison@yahoo.com> [Fri, 19 Jul 2024 20:09:48 -0400] rev 51722
typing: add type hints to the `charencode` module Since this module is dynamically imported from either `mercurial.pure` or `mercurial.cext`, these hints aren't detected in `mercurial.encoding`, and need to be imported directly there during the type-checking phase. This keeps the runtime selection via the policy config in place, but allows pytype to see these as functions with proper signatures instead of just `Any`. We don't attempt to import the `mercurial.cext` version yet because there's no types stubs for that module, but this will get the ball rolling. I thought this would spill over into other modules from there, but the only two *.pyi files that changed were for `encoding` and `charencode`. Applying this to other dynamically selected modules will clean some things up in other files, so this is a start. I had originally redefined the functions in the type-checking block (like some of the `os.path` aliasing in `mercurial.util`), but this is better because we won't have another duplication of the definitions that may get out of date.
Fri, 19 Jul 2024 16:49:46 -0400 typing: explicitly type some `mercurial.util` eol code to avoid @overload
Matt Harbison <matt_harbison@yahoo.com> [Fri, 19 Jul 2024 16:49:46 -0400] rev 51721
typing: explicitly type some `mercurial.util` eol code to avoid @overload Unlike the previous commit, this makes a material difference in the generated stub file- the `pycompat.identity()` aliases generated an @overload like this: @overload def fromnativeeol(a: _T0) -> _T0: ... ... which might fail to detect a bad argument, like str. This drops the @overload for the 3 related methods, so there's a single definition for each. The `typelib.BinaryIO_Proxy` is used for subclassing (the same as was done in 8147abc05794), so that it is a `BinaryIO` type during type checking, but still inherits `object` at runtime. That way, we don't need to implement unused abstract methods.
Fri, 19 Jul 2024 16:38:53 -0400 typing: avoid some useless @overload definitions in `mercurial.util`
Matt Harbison <matt_harbison@yahoo.com> [Fri, 19 Jul 2024 16:38:53 -0400] rev 51720
typing: avoid some useless @overload definitions in `mercurial.util` Apparently pytype considered the name as well as the type of each argument, and generates @overload definitions if they don't match. At best this is clutter, and can easily be removed.
Thu, 18 Jul 2024 22:46:36 -0400 dirstate: stringify a few exception messages
Matt Harbison <matt_harbison@yahoo.com> [Thu, 18 Jul 2024 22:46:36 -0400] rev 51719
dirstate: stringify a few exception messages Built in exceptions want str, and ProgrammingError converts bytes to str internally (because it subclasses RuntimeError).
Thu, 18 Jul 2024 20:34:35 -0400 typing: add type hints to `mercurial.verify._normpath()`
Matt Harbison <matt_harbison@yahoo.com> [Thu, 18 Jul 2024 20:34:35 -0400] rev 51718
typing: add type hints to `mercurial.verify._normpath()` Since 10db46e128d4, pytype almost figured this out, going from `Any` -> `_T0`, but the intent is obvious.
Thu, 18 Jul 2024 20:16:31 -0400 typing: add type hints to `i18n._msgcache`
Matt Harbison <matt_harbison@yahoo.com> [Thu, 18 Jul 2024 20:16:31 -0400] rev 51717
typing: add type hints to `i18n._msgcache` Since 10db46e128d4, pytype stopped inferring that the key is bytes.
Thu, 18 Jul 2024 19:57:42 -0400 typing: add type hints to `mercurial.dirstatemap`
Matt Harbison <matt_harbison@yahoo.com> [Thu, 18 Jul 2024 19:57:42 -0400] rev 51716
typing: add type hints to `mercurial.dirstatemap` Somewhere since 10db46e128d4, pytype stopped being able to infer the type of the `identity` field. Fill in some obvious other hints along the way. These hints caused pytype to flag a missing attribute: File "/mnt/c/Users/Matt/hg/mercurial/dirstatemap.py", line 714, in _v1_map: No attribute 'stat' on mercurial.windows.cachestat [attribute-error] In Union[Any, mercurial.posix.cachestat, mercurial.windows.cachestat] File "/mnt/c/Users/Matt/hg/mercurial/dirstatemap.py", line 715, in _v1_map: No attribute 'stat' on mercurial.windows.cachestat [attribute-error] In Union[Any, mercurial.posix.cachestat, mercurial.windows.cachestat] In practice, the `identity` field is NOT replaced with None if it isn't cacheable, so it's probably safer to just add the field and set it to None, since that check is already in place on line 715.
Thu, 18 Jul 2024 19:55:51 -0400 typing: add type hints to `cmdutil.findrepo()`
Matt Harbison <matt_harbison@yahoo.com> [Thu, 18 Jul 2024 19:55:51 -0400] rev 51715
typing: add type hints to `cmdutil.findrepo()` Since 10db46e128d4, pytype almost figured this out, going from `Any` -> `_T0`, but the intent is obvious.
Thu, 18 Jul 2024 19:01:55 -0400 typing: add some type hints to fastannotate that have decayed in the last year
Matt Harbison <matt_harbison@yahoo.com> [Thu, 18 Jul 2024 19:01:55 -0400] rev 51714
typing: add some type hints to fastannotate that have decayed in the last year Somewhere since 10db46e128d4, `_knownopts` decayed to `set` for unknown reasons. Also, `annotateopts.default` changed from bytes to str. While that is correct, I noticed that PyCharm was flagging the member fields as undefined in `shortstr()`, so add those to keep it happy. (There are no complaints from pytype because that module is excluded, due to the missing reference to `linelog.copyfrom()` that I'm not sure how to fix.)
Tue, 23 Jul 2024 12:12:22 +0200 heptapod-ci: use new v2.1 image
Raphaël Gomès <rgomes@octobus.net> [Tue, 23 Jul 2024 12:12:22 +0200] rev 51713
heptapod-ci: use new v2.1 image This is finally catching up to ~3 years of tech debt.
Tue, 23 Jul 2024 12:12:03 +0200 heptapod-ci: move version prints closer to the start
Raphaël Gomès <rgomes@octobus.net> [Tue, 23 Jul 2024 12:12:03 +0200] rev 51712
heptapod-ci: move version prints closer to the start This makes debugging a lot easier if anything is to go wrong, and shows output earlier.
(0) -30000 -10000 -3000 -1000 -300 -100 -16 +16 +100 tip