Mercurial > hg
view mercurial/templates/map-cmdline.xml @ 49803:55d45d0de4e7
typing: add type hints to pycompat.bytestr
The problem with leaving pytype to its own devices here was that for functions
that returned a bytestr, pytype inferred `Union[bytes, int]`. It now accepts
that it can be treated as plain bytes.
I wasn't able to figure out the arg type for `__getitem__`- `SupportsIndex`
(which PyCharm indicated is how the superclass function is typed) got flagged:
File "/mnt/c/Users/Matt/hg/mercurial/pycompat.py", line 236, in __getitem__:
unsupported operand type(s) for item retrieval: bytestr and SupportsIndex [unsupported-operands]
Function __getitem__ on bytestr expects int
But some caller got flagged when I marked it as `int`.
There's some minor spillover problems elsewhere- pytype doesn't seem to
recognize that `bytes.startswith()` can optionally take a 3rd and 4th arg, so
those few places have the warning disabled. It also flags where the tar API is
being abused, but that would be a tricky refactor (and would require typing
extensions until py3.7 is dropped), so disable those too.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Wed, 14 Dec 2022 01:51:33 -0500 |
parents | f4aeb952ab77 |
children |
line wrap: on
line source
[templates] docheader = '<?xml version="1.0"?>\n<log>\n' docfooter = '</log>\n' changeset = '<logentry revision="{rev}" node="{node}">\n{branches}{bookmarks}{tags}{parents}<author email="{author|email|xmlescape}">{author|person|xmlescape}</author>\n<date>{date|rfc3339date}</date>\n<msg xml:space="preserve">{desc|xmlescape}</msg>\n</logentry>\n' changeset_verbose = '<logentry revision="{rev}" node="{node}">\n{branches}{bookmarks}{tags}{parents}<author email="{author|email|xmlescape}">{author|person|xmlescape}</author>\n<date>{date|rfc3339date}</date>\n<msg xml:space="preserve">{desc|xmlescape}</msg>\n<paths>\n{file_adds}{file_dels}{file_mods}</paths>\n{file_copies}</logentry>\n' changeset_debug = '<logentry revision="{rev}" node="{node}">\n{branches}{bookmarks}{tags}{parents}<author email="{author|email|xmlescape}">{author|person|xmlescape}</author>\n<date>{date|rfc3339date}</date>\n<msg xml:space="preserve">{desc|xmlescape}</msg>\n<paths>\n{file_adds}{file_dels}{file_mods}</paths>\n{file_copies}{extras}</logentry>\n' file_add = '<path action="A">{file_add|xmlescape}</path>\n' file_mod = '<path action="M">{file_mod|xmlescape}</path>\n' file_del = '<path action="R">{file_del|xmlescape}</path>\n' start_file_copies = '<copies>\n' file_copy = '<copy source="{source|xmlescape}">{name|xmlescape}</copy>\n' end_file_copies = '</copies>\n' parent = '<parent revision="{rev}" node="{node}" />\n' branch = '<branch>{branch|xmlescape}</branch>\n' tag = '<tag>{tag|xmlescape}</tag>\n' bookmark = '<bookmark>{bookmark|xmlescape}</bookmark>\n' extra = '<extra key="{key|xmlescape}">{value|xmlescape}</extra>\n'