Skip to content
Snippets Groups Projects
  1. Nov 08, 2024
  2. Oct 26, 2024
  3. Sep 19, 2024
  4. Aug 20, 2024
    • Matt Harbison's avatar
      contrib: print the version of pytype used to do the type checking · 68ec9743ef04
      Matt Harbison authored
      This will help with CI.  I don't see a way to print the version of python that's
      running it.  When I tried `head -n 1 $(which pytype)`, the CI run printed:
      
          #!/usr/bin/env bash
      
      Locally, that gives the path to the python interpreter in the venv, so IDK
      what's different.
      68ec9743ef04
  5. Aug 04, 2024
  6. Jul 25, 2024
  7. Dec 18, 2023
  8. Dec 20, 2023
  9. Jul 21, 2023
  10. Jan 06, 2023
  11. Jan 04, 2023
  12. Dec 10, 2022
  13. Nov 25, 2022
    • Matt Harbison's avatar
      pytype: stop excluding mercurial/ui.py · 8147abc05794
      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
      8147abc05794
  14. Nov 24, 2022
  15. Sep 28, 2022
    • Matt Harbison's avatar
      tests: migrate the pytype test to a shell script for easier CI processing · 08c3ecd899ae
      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.
      08c3ecd899ae
  16. Mar 22, 2022
  17. Dec 15, 2021
    • Matt Harbison's avatar
      pytype: stop excluding ssutil.py · 08af0adc235c
      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
      08af0adc235c
    • Matt Harbison's avatar
      pytype: stop excluding wireprotoserver.py · 81805bba11f9
      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
      81805bba11f9
  18. Dec 14, 2021
    • Matt Harbison's avatar
      pytype: stop excluding pycompat.py · 12a43f857a11
      Matt Harbison authored
      Whatever issues were here seem to have been previously fixed.
      
      Differential Revision: https://phab.mercurial-scm.org/D11929
      12a43f857a11
    • Matt Harbison's avatar
      pytype: stop excluding procutil.py · 333a2656e981
      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
      333a2656e981
    • Matt Harbison's avatar
      pytype: stop excluding chgserver.py · 7caaefa48794
      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
      7caaefa48794
    • Matt Harbison's avatar
      pytype: stop excluding webcommands.py · ea13dabbe168
      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
      ea13dabbe168
    • Matt Harbison's avatar
      8a075b679918
    • Matt Harbison's avatar
      pytype: stop excluding patch.py · 290f9c150f70
      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
      290f9c150f70
    • Matt Harbison's avatar
      pytype: stop excluding statprof.py · d2fff292c265
      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
      d2fff292c265
  19. Dec 13, 2021
    • Matt Harbison's avatar
      pytype: stop excluding wireprotov2server.py · cfb4f1dee978
      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
      cfb4f1dee978
    • Matt Harbison's avatar
      pytype: stop excluding stringutil.py · dcdecec401ca
      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
      dcdecec401ca
    • Matt Harbison's avatar
      pytype: stop excluding cmdutil.py · 3444e0b39c30
      Matt Harbison authored
      Whatever was broken here seems to have been previously fixed.
      
      Differential Revision: https://phab.mercurial-scm.org/D11917
      3444e0b39c30
    • Matt Harbison's avatar
      pytype: stop excluding copies.py · 79b904313357
      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
      79b904313357
    • Matt Harbison's avatar
      pytype: stop excluding lsprof.py · abac7983d28e
      Matt Harbison authored
      Whatever was previously flagged in this file appears to have been fixed.
      
      Differential Revision: https://phab.mercurial-scm.org/D11913
      abac7983d28e
    • Matt Harbison's avatar
      pytype: stop excluding changegroup.py · 8843c9a8771b
      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
      8843c9a8771b
    • Matt Harbison's avatar
      pytype: stop excluding upgrade.py · a4d8de93023c
      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
      a4d8de93023c
  20. Mar 26, 2021
  21. Mar 19, 2021
Loading