Commits on Source (8)
-
Matt Harbison authored9be765b82a90
-
Matt Harbison authored
Flagged by pytype 2022.11.18 when the cext stubs are made visible to it. There are very likely other signatures that are missing, but this is enough to keep it happy for now.
df5d3b0d6472 -
Matt Harbison authored
Unfortunately, pytype doesn't support this yet. But it was included with the attr package, so we might as well do it here for consistency. Unlike the attr package, these type hints are only partial, so they are marked as such[1] (but who knows if it matters, given these are C extensions, so no local source code to scan). [1] https://peps.python.org/pep-0561/#partial-stub-packages
2e34ea45aaea -
Matt Harbison authored
The same logic is in the TortoiseHg tests for running pytype, and it's useful to know if a new version of pytype is better or worse.
3e1869751cfe -
Matt Harbison authored
I really hate this, but pytype doesn't support PEP 561 and doesn't seem to have the equivalent of `MYPYPATH` to point to custom stubs. Ignoring the vendored stubs isn't necessarily harmful, but pytype has been choking on the vendored attr package after pytype 2022.03.29 with errors like this: File "/mnt/c/Users/Matt/hg/mercurial/linelog.py", line 52, in __iter__: Built-in function iter was called with the wrong arguments [wrong-arg-types] Expected: (collection: bytearray) Actually passed: (collection: mercurial.thirdparty.attr._make._CountingAttr) File "/mnt/c/Users/Matt/hg/mercurial/dirstateutils/v2.py", line 143, in pack: Built-in function len was called with the wrong arguments [wrong-arg-types] Expected: (obj: Sized) Actually passed: (obj: mercurial.thirdparty.attr._make._CountingAttr) Attributes of protocol Sized are not implemented on mercurial.thirdparty.attr._make._CountingAttr: __len__ File "/mnt/c/Users/Matt/hg/mercurial/dirstateutils/v2.py", line 144, in pack: No attribute 'rfind' on mercurial.thirdparty.attr._make._CountingAttr [attribute-error] File "/mnt/c/Users/Matt/hg/mercurial/dirstateutils/v2.py", line 146, in pack: Built-in function len was called with the wrong arguments [wrong-arg-types] Expected: (obj: Sized) Actually passed: (obj: mercurial.thirdparty.attr._make._CountingAttr) Attributes of protocol Sized are not implemented on mercurial.thirdparty.attr._make._CountingAttr: __len__ File "/mnt/c/Users/Matt/hg/mercurial/dirstateutils/v2.py", line 152, in pack: No attribute 'v2_data' on mercurial.thirdparty.attr._make._CountingAttr [attribute-error] File "/mnt/c/Users/Matt/hg/mercurial/util.py", line 2817, in go: unsupported operand type(s) for /: 'count: mercurial.thirdparty.attr._make._CountingAttr' and 'float: float' [unsupported-operands] No attribute '__truediv__' on 'count: mercurial.thirdparty.attr._make._CountingAttr' or '__rtruediv__' on 'float: float' Called from (traceback): line 2981, in __bytes__ This is essentially the same hack we've been using in TortoiseHg to add the vendored PyQt5 stubs. What I don't understand is pytype *still* generates *.pyi files under .pytype/pyi/mercurial/thirdparty/attr, even when the package is explicitly ignored in the pytype command line args. But it avoids the errors, which means we aren't stuck on pytype==2022.03.29. https://github.com/google/pytype/issues/151
03792c1ed341 -
Matt Harbison authored
Since CI runs from docker images, it doesn't matter that this mucks with the typeshed bundled with pytype.
556efeea6dbf -
Matt Harbison authored
No particular reason, other than the current build is fairly old. It flagged a few more things (that weren't errors based on the logic around them), but OTOH, some of the pyi stubs it generates are less specific.
86e398a3d598 -
Matt Harbison authored
While pytype may not support PEP 561, PyCharm does, so having the stubs available means it can determine `foo = attr.ib(type=int)` means `foo` is an int. This only applies when using Mercurial as a library, like with TortoiseHg development- PyCharm is already smart enough to use the *.pyi files in the Mercurial source tree when hacking on Mercurial itself. I left the mercurial.cext stubs out because it seems very low level, that 3rd parties shouldn't be using directly.
54421ef8a423
Showing
- contrib/check-pytype.sh 3 additions, 0 deletionscontrib/check-pytype.sh
- contrib/heptapod-ci.yml 2 additions, 1 deletioncontrib/heptapod-ci.yml
- contrib/setup-pytype.sh 33 additions, 0 deletionscontrib/setup-pytype.sh
- mercurial/bundle2.py 5 additions, 0 deletionsmercurial/bundle2.py
- mercurial/bundlecaches.py 5 additions, 1 deletionmercurial/bundlecaches.py
- mercurial/cext/parsers.pyi 4 additions, 0 deletionsmercurial/cext/parsers.pyi
- mercurial/cext/py.typed 1 addition, 0 deletionsmercurial/cext/py.typed
- mercurial/utils/stringutil.py 4 additions, 0 deletionsmercurial/utils/stringutil.py
- setup.py 4 additions, 0 deletionssetup.py
contrib/setup-pytype.sh
0 → 100755
mercurial/cext/py.typed
0 → 100644