Skip to content
Snippets Groups Projects
  1. Dec 18, 2023
    • Anton Shestakov's avatar
      pytype: update check-pytype.sh to select target automatically · 05ce07bd
      Anton Shestakov authored
      We have python3.11 on CI, so we can run pytype targeting that version. On the
      other hand, we don't have python3.7 on CI anymore, so we can't run pytype for
      3.7 anymore (interpreter not found). I think it's fine to make pytype select
      the appropriate target depending on the version of the interpreter it's running
      under.
      05ce07bd
  2. Dec 20, 2023
  3. Jul 21, 2023
  4. Jan 06, 2023
  5. Jan 04, 2023
  6. Dec 10, 2022
  7. Nov 25, 2022
    • Matt Harbison's avatar
      pytype: stop excluding mercurial/ui.py · 8147abc0
      Matt Harbison authored
      ui.extractchoices() is perhaps making assumptions that it shouldn't about the
      pattern always matching, but presumably we have test coverage for that.
      
      PyCharm flags the updated classes with a warning "Class xxx must implement all
      abstract methods", and suggests adding `abc.ABC` to the superclasses.  I'm not
      sure why, unless it doesn't recognize the `__getattr__()` delegation pattern.
      Additionally, we can't unconditionally subclass `typing.BinaryIO` because that
      defeats the `__getattr__` delegation to the wrapped object at runtime.  Instead,
      it has to only subclass during the type checking phase[1].
      
      In any event, this fixes:
      
          File "/mnt/c/Users/Matt/hg/mercurial/ui.py", line 1518, in _runpager:
              Function subprocess.Popen.__new__ was called with the wrong arguments [wrong-arg-types]
                   Expected: (cls, args, bufsize, executable, stdin,
                              stdout: Optional[Union[IO, int]] = ..., ...)
            Actually passed: (cls, args, bufsize, stdin,
                              stdout: Union[mercurial.utils.procutil.WriteAllWrapper,
                                      mercurial.windows.winstdout], ...)
          File "/mnt/c/Users/Matt/hg/mercurial/ui.py", line 1798, in extractchoices:
              No attribute 'group' on None [attribute-error]
            In Optional[Match[bytes]]
          File "/mnt/c/Users/Matt/hg/mercurial/ui.py", line 1799, in extractchoices:
              No attribute 'group' on None [attribute-error]
            In Optional[Match[bytes]]
      
      [1] https://stackoverflow.com/q/71365594
      8147abc0
  8. Nov 24, 2022
  9. Sep 28, 2022
    • Matt Harbison's avatar
      tests: migrate the pytype test to a shell script for easier CI processing · 08c3ecd8
      Matt Harbison authored
      There have been recent hangs and timeout, but it's hard to debug because the *.t
      test redirects output to a file and only prints it if `pytype` actually exits.
      This shell script can be run directly by CI, and will allow more flexibility to
      try to cache and restore type stubs for further speed increases.
      08c3ecd8
  10. Mar 22, 2022
  11. Dec 15, 2021
    • Matt Harbison's avatar
      pytype: stop excluding ssutil.py · 08af0adc
      Matt Harbison authored
      Pytype simply can't distinguish the type for this one entry's value from the
      other values:
      
        File "/mnt/c/Users/Matt/hg/mercurial/sslutil.py", line 142, in _hostsettings:
            No attribute 'append' on None [attribute-error]
          In Optional[Union[Any, List[nothing], bool, bytes]]
        File "/mnt/c/Users/Matt/hg/mercurial/sslutil.py", line 142, in _hostsettings:
            No attribute 'append' on bool [attribute-error]
          In Optional[Union[Any, List[nothing], bool, bytes]]
        File "/mnt/c/Users/Matt/hg/mercurial/sslutil.py", line 142, in _hostsettings:
            No attribute 'append' on bytes [attribute-error]
          In Optional[Union[Any, List[nothing], bool, bytes]]
        File "/mnt/c/Users/Matt/hg/mercurial/sslutil.py", line 147, in _hostsettings:
            No attribute 'append' on None [attribute-error]
          In Optional[Union[Any, List[Tuple[Any, Any]], bool, bytes]]
        File "/mnt/c/Users/Matt/hg/mercurial/sslutil.py", line 147, in _hostsettings:
            No attribute 'append' on bool [attribute-error]
          In Optional[Union[Any, List[Tuple[Any, Any]], bool, bytes]]
        File "/mnt/c/Users/Matt/hg/mercurial/sslutil.py", line 147, in _hostsettings:
            No attribute 'append' on bytes [attribute-error]
          In Optional[Union[Any, List[Tuple[Any, Any]], bool, bytes]]
      
      Differential Revision: https://phab.mercurial-scm.org/D11931
      08af0adc
    • Matt Harbison's avatar
      pytype: stop excluding wireprotoserver.py · 81805bba
      Matt Harbison authored
      The `config` entry is a 2 part tuple, which has `__iter__()`:
      
        File "/mnt/c/Users/Matt/hg/mercurial/wireprotoserver.py", line 253, in _availableapis:
            No attribute '__iter__' on Callable[[Any, Any], Any] [attribute-error]
          In Union[Callable[[Any, Any, Any, Any, Any], None], Callable[[Any, Any], Any]]
        File "/mnt/c/Users/Matt/hg/mercurial/wireprotoserver.py", line 253, in _availableapis:
            No attribute '__iter__' on Callable[[Any, Any, Any, Any, Any], None] [attribute-error]
          In Union[Callable[[Any, Any, Any, Any, Any], None], Callable[[Any, Any], Any]]
      
      Differential Revision: https://phab.mercurial-scm.org/D11930
      81805bba
  12. Dec 14, 2021
    • Matt Harbison's avatar
      pytype: stop excluding pycompat.py · 12a43f85
      Matt Harbison authored
      Whatever issues were here seem to have been previously fixed.
      
      Differential Revision: https://phab.mercurial-scm.org/D11929
      12a43f85
    • Matt Harbison's avatar
      pytype: stop excluding procutil.py · 333a2656
      Matt Harbison authored
      This avoids these false warnings:
      
        File "/mnt/c/Users/Matt/hg/mercurial/utils/procutil.py", line 78, in <module>:
            No attribute 'register' on Type[io.BufferedIOBase] [attribute-error]
        File "/mnt/c/Users/Matt/hg/mercurial/utils/procutil.py", line 117, in <module>:
            No attribute 'register' on Type[io.IOBase] [attribute-error]
        File "/mnt/c/Users/Matt/hg/mercurial/utils/procutil.py", line 770, in runbgcommandpy3:
            No attribute 'close' on int [attribute-error]
          In Union[IO[Union[bytes, str]], int]
      
      Differential Revision: https://phab.mercurial-scm.org/D11927
      333a2656
    • Matt Harbison's avatar
      pytype: stop excluding chgserver.py · 7caaefa4
      Matt Harbison authored
      This teaches pytype about some lazy initialization, and avoids the following:
      
        File "/mnt/c/Users/Matt/hg/mercurial/chgserver.py", line 666, in _checkextensions:
            No attribute '_hashstate' on chgunixservicehandler [attribute-error]
        File "/mnt/c/Users/Matt/hg/mercurial/chgserver.py", line 672, in _checkextensions:
            No attribute '_hashstate' on chgunixservicehandler [attribute-error]
        File "/mnt/c/Users/Matt/hg/mercurial/chgserver.py", line 677, in _bind:
            No attribute '_realaddress' on chgunixservicehandler [attribute-error]
        File "/mnt/c/Users/Matt/hg/mercurial/chgserver.py", line 683, in _bind:
            No attribute '_realaddress' on chgunixservicehandler [attribute-error]
        File "/mnt/c/Users/Matt/hg/mercurial/chgserver.py", line 686, in _createsymlink:
            No attribute '_baseaddress' on chgunixservicehandler [attribute-error]
        File "/mnt/c/Users/Matt/hg/mercurial/chgserver.py", line 686, in _createsymlink:
            No attribute '_realaddress' on chgunixservicehandler [attribute-error]
        File "/mnt/c/Users/Matt/hg/mercurial/chgserver.py", line 688, in _createsymlink:
            No attribute '_baseaddress' on chgunixservicehandler [attribute-error]
        File "/mnt/c/Users/Matt/hg/mercurial/chgserver.py", line 689, in _createsymlink:
            No attribute '_realaddress' on chgunixservicehandler [attribute-error]
        File "/mnt/c/Users/Matt/hg/mercurial/chgserver.py", line 690, in _createsymlink:
            No attribute '_baseaddress' on chgunixservicehandler [attribute-error]
      
      Differential Revision: https://phab.mercurial-scm.org/D11926
      7caaefa4
    • Matt Harbison's avatar
      pytype: stop excluding webcommands.py · ea13dabb
      Matt Harbison authored
      I have no idea why, but asserting that each value added to `emptydirs` is not
      None didn't fix this:
      
        File "/mnt/c/Users/Matt/hg/mercurial/hgweb/webcommands.py", line 621, in dirlist:
            Function bytes.join was called with the wrong arguments [wrong-arg-types]
                 Expected: (self, iterable: Iterable[bytes])
          Actually passed: (self, iterable: List[None])
      
      Differential Revision: https://phab.mercurial-scm.org/D11924
      ea13dabb
    • Matt Harbison's avatar
    • Matt Harbison's avatar
      pytype: stop excluding patch.py · 290f9c15
      Matt Harbison authored
      The underlying `email.generator.BytesGenerator` is documented as requiring an
      `fp` that accepts bytes, so I'm not sure why pytype is getting confused:
      
        File "/mnt/c/Users/Matt/hg/mercurial/patch.py", line 112, in msgfp:
            Function Generator.__init__ was called with the wrong arguments [wrong-arg-types]
                 Expected: (self, outfp: TextIO, ...)
          Actually passed: (self, outfp: io.BytesIO, ...)
      
      Differential Revision: https://phab.mercurial-scm.org/D11922
      290f9c15
    • Matt Harbison's avatar
      pytype: stop excluding statprof.py · d2fff292
      Matt Harbison authored
      This seems to have worked fine before (at least on Linux).  We could just add
      suppression comments, but this file already imports from the mercurial package,
      which seems to prevent this from running as a standalone program because of the
      relative import of `pycompat`.  PyCharm isn't happy either way.
      
        File "/mnt/c/Users/Matt/hg/mercurial/statprof.py", line 501, in display:
            Function TextIO.write was called with the wrong arguments [wrong-arg-types]
                 Expected: (self, s: str)
          Actually passed: (self, s: bytes)
        Called from (traceback):
          line 1091, in main
        File "/mnt/c/Users/Matt/hg/mercurial/statprof.py", line 501, in display:
            Function TextIO.write was called with the wrong arguments [wrong-arg-types]
                 Expected: (self, s: str)
          Actually passed: (self, s: bytes)
        Called from (traceback):
          line 431, in profile
        File "/mnt/c/Users/Matt/hg/mercurial/statprof.py", line 522, in display:
            Function TextIO.write was called with the wrong arguments [wrong-arg-types]
                 Expected: (self, s: str)
          Actually passed: (self, s: bytes)
        Called from (traceback):
          line 1091, in main
        File "/mnt/c/Users/Matt/hg/mercurial/statprof.py", line 522, in display:
            Function TextIO.write was called with the wrong arguments [wrong-arg-types]
                 Expected: (self, s: str)
          Actually passed: (self, s: bytes)
        Called from (traceback):
          line 431, in profile
        File "/mnt/c/Users/Matt/hg/mercurial/statprof.py", line 523, in display:
            Function TextIO.write was called with the wrong arguments [wrong-arg-types]
                 Expected: (self, s: str)
          Actually passed: (self, s: bytes)
        Called from (traceback):
          line 1091, in main
        File "/mnt/c/Users/Matt/hg/mercurial/statprof.py", line 523, in display:
            Function TextIO.write was called with the wrong arguments [wrong-arg-types]
                 Expected: (self, s: str)
          Actually passed: (self, s: bytes)
        Called from (traceback):
          line 431, in profile
        File "/mnt/c/Users/Matt/hg/mercurial/statprof.py", line 524, in display:
            Function TextIO.write was called with the wrong arguments [wrong-arg-types]
                 Expected: (self, s: str)
          Actually passed: (self, s: bytes)
        Called from (traceback):
          line 1091, in main
        File "/mnt/c/Users/Matt/hg/mercurial/statprof.py", line 524, in display:
            Function TextIO.write was called with the wrong arguments [wrong-arg-types]
                 Expected: (self, s: str)
          Actually passed: (self, s: bytes)
        Called from (traceback):
          line 431, in profile
        File "/mnt/c/Users/Matt/hg/mercurial/statprof.py", line 796, in _write:
            Function TextIO.write was called with the wrong arguments [wrong-arg-types]
                 Expected: (self, s: str)
          Actually passed: (self, s: bytes)
      
      Differential Revision: https://phab.mercurial-scm.org/D11921
      d2fff292
  13. Dec 13, 2021
    • Matt Harbison's avatar
      pytype: stop excluding wireprotov2server.py · cfb4f1de
      Matt Harbison authored
      This fixes:
      
        File "/mnt/c/Users/Matt/hg/mercurial/wireprotov2server.py", line 584, in _capabilitiesv2:
            unsupported operand type(s) for item assignment: Set[bytes] [unsupported-operands]
          No attribute '__setitem__' on Set[bytes]
        File "/mnt/c/Users/Matt/hg/mercurial/wireprotov2server.py", line 611, in _capabilitiesv2:
            No attribute 'append' on dict [attribute-error]
          In Union[List[bytes], List[nothing], dict]
        Called from (traceback):
          line 543, in httpv2apidescriptor
      
      Differential Revision: https://phab.mercurial-scm.org/D11919
      cfb4f1de
    • Matt Harbison's avatar
      pytype: stop excluding stringutil.py · dcdecec4
      Matt Harbison authored
      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
      dcdecec4
    • Matt Harbison's avatar
      pytype: stop excluding cmdutil.py · 3444e0b3
      Matt Harbison authored
      Whatever was broken here seems to have been previously fixed.
      
      Differential Revision: https://phab.mercurial-scm.org/D11917
      3444e0b3
    • Matt Harbison's avatar
      pytype: stop excluding copies.py · 79b90431
      Matt Harbison authored
      I can't prove that `targetrev` is always in `all_copies`, but it would have been
      a runtime error before too if it's not.
      
      Differential Revision: https://phab.mercurial-scm.org/D11916
      79b90431
    • Matt Harbison's avatar
      pytype: stop excluding lsprof.py · abac7983
      Matt Harbison authored
      Whatever was previously flagged in this file appears to have been fixed.
      
      Differential Revision: https://phab.mercurial-scm.org/D11913
      abac7983
    • Matt Harbison's avatar
      pytype: stop excluding changegroup.py · 8843c9a8
      Matt Harbison authored
      The false positives that were detected seem to be related to what happens to the
      variables after the local methods are used:
      
        File "/mnt/c/Users/Matt/hg/mercurial/changegroup.py", line 353, in ondupchangelog:
            No attribute 'append' on range [attribute-error]
          In Union[List[nothing], range]
        File "/mnt/c/Users/Matt/hg/mercurial/changegroup.py", line 357, in onchangelog:
            No attribute 'update' on None [attribute-error]
      
      Differential Revision: https://phab.mercurial-scm.org/D11912
      8843c9a8
    • Matt Harbison's avatar
      pytype: stop excluding upgrade.py · a4d8de93
      Matt Harbison authored
      The sole failure here was this, which is fixed by simply creating a set like the
      caller, instead of a dict:
      
        File "/mnt/c/Users/Matt/hg/mercurial/upgrade.py", line 73, in upgraderepo:
            No attribute 'discard' on Dict[nothing, nothing] [attribute-error]
          In Union[Any, Dict[nothing, nothing]]
      
      Differential Revision: https://phab.mercurial-scm.org/D11911
      a4d8de93
  14. Mar 26, 2021
  15. Mar 19, 2021
Loading