typing: disable `signature-mismatch` warnings on a few bytestr functions
authorMatt Harbison <matt_harbison@yahoo.com>
Sun, 19 Feb 2023 00:04:53 -0500
changeset 50101 b900f40c343e
parent 50099 0f0880c8a7e5
child 50102 c4b17bc78d8c
typing: disable `signature-mismatch` warnings on a few bytestr functions Recent versions of pytype complain about this, but it seems like expected behavior.
mercurial/pycompat.py
--- a/mercurial/pycompat.py	Sat Feb 18 02:39:32 2023 +0100
+++ b/mercurial/pycompat.py	Sun Feb 19 00:04:53 2023 -0500
@@ -244,13 +244,17 @@
             s = str(s).encode('ascii')
         return bytes.__new__(cls, s)
 
-    def __getitem__(self, key) -> bytes:
+    # The base class uses `int` return in py3, but the point of this class is to
+    # behave like py2.
+    def __getitem__(self, key) -> bytes:  # pytype: disable=signature-mismatch
         s = bytes.__getitem__(self, key)
         if not isinstance(s, bytes):
             s = bytechr(s)
         return s
 
-    def __iter__(self) -> Iterator[bytes]:
+    # The base class expects `Iterator[int]` return in py3, but the point of
+    # this class is to behave like py2.
+    def __iter__(self) -> Iterator[bytes]:  # pytype: disable=signature-mismatch
         return iterbytestr(bytes.__iter__(self))
 
     def __repr__(self) -> str: