changeset 51941:e58f02e2f6a9

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.
author Matt Harbison <matt_harbison@yahoo.com>
date Sat, 05 Oct 2024 17:32:26 -0400
parents 54d9f496f07a
children 73a43fe3e6fd
files mercurial/cext/parsers.pyi
diffstat 1 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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