pytype: stop excluding stringutil.py
authorMatt Harbison <matt_harbison@yahoo.com>
Mon, 13 Dec 2021 14:43:10 -0500
changeset 48479 dcdecec401ca
parent 48478 3444e0b39c30
child 48480 cfb4f1dee978
pytype: stop excluding stringutil.py This fixes the following: File "/mnt/c/Users/Matt/hg/mercurial/utils/stringutil.py", line 267, in prettyrepr: Function bytes.startswith expects 2 arg(s), got 3 [wrong-arg-count] Expected: (self, prefix) Actually passed: (self, prefix, _) File "/mnt/c/Users/Matt/hg/mercurial/utils/stringutil.py", line 695, in escapestr: No attribute 'escape_encode' on module 'codecs' [module-attr] File "/mnt/c/Users/Matt/hg/mercurial/utils/stringutil.py", line 699, in unescapestr: No attribute 'escape_decode' on module 'codecs' [module-attr] Differential Revision: https://phab.mercurial-scm.org/D11918
mercurial/utils/stringutil.py
tests/test-check-pytype.t
--- a/mercurial/utils/stringutil.py	Mon Dec 13 00:25:38 2021 -0500
+++ b/mercurial/utils/stringutil.py	Mon Dec 13 14:43:10 2021 -0500
@@ -264,7 +264,11 @@
         q1 = rs.find(b'<', p1 + 1)
         if q1 < 0:
             q1 = len(rs)
+            # pytype: disable=wrong-arg-count
+            # TODO: figure out why pytype doesn't recognize the optional start
+            #  arg
         elif q1 > p1 + 1 and rs.startswith(b'=', q1 - 1):
+            # pytype: enable=wrong-arg-count
             # backtrack for ' field=<'
             q0 = rs.rfind(b' ', p1 + 1, q1 - 1)
         if q0 < 0:
@@ -692,11 +696,11 @@
         s = bytes(s)
     # call underlying function of s.encode('string_escape') directly for
     # Python 3 compatibility
-    return codecs.escape_encode(s)[0]
+    return codecs.escape_encode(s)[0]  # pytype: disable=module-attr
 
 
 def unescapestr(s):
-    return codecs.escape_decode(s)[0]
+    return codecs.escape_decode(s)[0]  # pytype: disable=module-attr
 
 
 def forcebytestr(obj):
--- a/tests/test-check-pytype.t	Mon Dec 13 00:25:38 2021 -0500
+++ b/tests/test-check-pytype.t	Mon Dec 13 14:43:10 2021 -0500
@@ -38,7 +38,6 @@
 mercurial/unionrepo.py        # ui, svfs, unfiltered [attribute-error]
 mercurial/util.py             # [attribute-error], [wrong-arg-count]
 mercurial/utils/procutil.py   # [attribute-error], [module-attr], [bad-return-type]
-mercurial/utils/stringutil.py # [module-attr], [wrong-arg-count]
 mercurial/utils/memorytop.py  # not 3.6 compatible
 mercurial/win32.py            # [not-callable]
 mercurial/wireprotoframing.py # [unsupported-operands], [attribute-error], [import-error]
@@ -80,7 +79,6 @@
   >    -x mercurial/ui.py \
   >    -x mercurial/unionrepo.py \
   >    -x mercurial/utils/procutil.py \
-  >    -x mercurial/utils/stringutil.py \
   >    -x mercurial/utils/memorytop.py \
   >    -x mercurial/win32.py \
   >    -x mercurial/wireprotoframing.py \