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.
--- a/mercurial/cext/parsers.pyi Sat Oct 05 15:00:37 2024 -0400
+++ b/mercurial/cext/parsers.pyi Sat Oct 05 17:32:26 2024 -0400
@@ -12,6 +12,21 @@
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