# HG changeset patch # User Matt Harbison # Date 2024-10-05 21:32:26 # Node ID e58f02e2f6a903f78793f7dc54dab5a449e6dacf # Parent 54d9f496f07a64fb3123eec0dec0ca5af5bb47ef typing: add stub functions for `cext/charencoding` I'm not sure if it's better to have a separate file, and currently pytype doesn't really know how to handle these, so it's no help in figuring that out. Technically, these methods are part of the `mercurial.cext.parsers` module, so put them into the existing stub until there's a reason to split it out. diff --git a/mercurial/cext/parsers.pyi b/mercurial/cext/parsers.pyi --- a/mercurial/cext/parsers.pyi +++ b/mercurial/cext/parsers.pyi @@ -12,6 +12,21 @@ from typing import ( version: int versionerrortext: str +# From charencode.c + +# Note: the first 'bytes' arg of isasciistr() can be typed as 'Buffer' from the +# typing_extensions backport, once the related bug is fixed in pytype, or pytype +# is run under py3.12. The arg for asciilower(), asciiupper() and +# jsonescapeu8fast() is checked specifically for the 'bytes' type. The 'bytes' +# return is an instance of 'bytes', not an alias for 'Buffer'. +# +# https://github.com/google/pytype/issues/1772 +def isasciistr(s: bytes) -> bool: ... +def asciilower(s: bytes) -> bytes: ... +def asciiupper(s: bytes) -> bytes: ... +def jsonescapeu8fast(u8chars: bytes, paranoid: bool) -> bytes: ... + + class DirstateItem: __doc__: str