D7295: pytype: add a (very slow) test that executes pytype
quark (Jun Wu)
phabricator at mercurial-scm.org
Fri Jan 31 14:58:54 EST 2020
quark added a comment.
> No, initially because I'd never heard of it, but now because I don't want to deal with ocaml. :)
The `pip install` version ships with a pre-compiled binary so an ocaml compiler is not needed.
> I'm dubious that it's doing anywhere near the checking of pytype if it manages to run to completion without errors. What does the output look like?
Good question. I wasn't aware about the differences and I read pytype's README and the examples apply to pyre. Pytype does type inference while pyre only checks function with stricter type annotations.
Pyre does complete (output <https://bpaste.net/7JCQ>). I wasn't able to get pytype past 44/251 (output <https://bpaste.net/CLEQ>). For files with type annotations like `mail.py`, it seems pyre output is useful:
# on commit d844202324924919bc517691052d39c520e077eb
mercurial/mail.py:57:4 Inconsistent override [15]: `mail.STARTTLS.starttls` overrides method defined in `smtplib.SMTP` inconsistently. The overriding method is not annotated but should return a subtype of `typing.Tuple[int, bytes]`.
mercurial/mail.py:387:22 Incompatible variable type [9]: charsets is declared to have type `List[str]` but is used as type `None`.
mercurial/mail.py:392:28 Incompatible parameter type [6]: Expected `bytes` for 2nd anonymous parameter to call `_encode` but got `Union[bytes, str]`.
mercurial/mail.py:394:33 Incompatible parameter type [6]: Expected `bytes` for 1st anonymous parameter to call `encoding.strfromlocal` but got `Union[bytes, str]`.
mercurial/mail.py:397:35 Incompatible variable type [9]: charsets is declared to have type `List[str]` but is used as type `None`.
mercurial/mail.py:399:4 Incompatible variable type [9]: addr is declared to have type `str` but is used as type `bytes`.
mercurial/mail.py:402:30 Incompatible parameter type [6]: Expected `typing.Optional[str]` for 1st anonymous parameter to call `str.split` but got `bytes`.
mercurial/mail.py:405:8 Incompatible variable type [9]: addr is declared to have type `str` but is used as type `bytes`.
mercurial/mail.py:414:63 Incompatible parameter type [6]: Expected `bytes` for 1st anonymous parameter to call `encoding.strfromlocal` but got `str`.
mercurial/mail.py:417:31 Incompatible variable type [9]: charsets is declared to have type `List[str]` but is used as type `None`.
mercurial/mail.py:426:30 Incompatible variable type [9]: charsets is declared to have type `List[str]` but is used as type `None`.
mercurial/mail.py:446:22 Incompatible variable type [9]: charsets is declared to have type `List[str]` but is used as type `None`.
mercurial/mail.py:499:52 Incompatible parameter type [6]: Expected `Union[email.header.Header, str]` for 1st anonymous parameter to call `email.header.decode_header` but got `Union[bytes, email.header.Header]`.
It seems to me that a combined approach might be interesting - use pytype to generate `pyi` files and pyre for faster checking.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D7295/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D7295
To: durin42, #hg-reviewers, indygreg
Cc: quark, marmoute, mharbison72, dlax, indygreg, mjpieters, mercurial-devel
More information about the Mercurial-devel
mailing list