Skip to content
Snippets Groups Projects

Make a few classes hidden behind interface decorators visible to pytype

Merged Matt Harbison requested to merge topic/default/typing-interfaces into branch/default
  1. Aug 22, 2024
    • Matt Harbison's avatar
      typing: lock in new pytype gains from making revlog related classes typeable · 0338fb200a30
      Matt Harbison authored
      These were pretty clean changes in the pyi files from earlier in this series, so
      add them to the code to make it more understandable.
      
      There's one more trivial hint that can be added to the return of
      `mercurial.revlogutils.rewrite._filelog_from_filename()`, however it needs to be
      imported from '..' under the conditional of `typing.TYPE_CHECKING`, and that
      seems to confuse the import checker- possibly because there's already an import
      block from that level.  (I would have expected a message about multiple import
      statements in this case, but got one about higher level imports should come
      first, no matter where I put the import statement.)
      0338fb200a30
  2. Aug 20, 2024
  3. Aug 21, 2024
    • Matt Harbison's avatar
      remotefilelog: adapt the `debugindex` command to past API changes · c371134fef01
      Matt Harbison authored
      Pytype was missing these problems because it's currently inferring the classes
      for `filelog` and `revlog` to be `Any`.  When that's fixed, these were flagged,
      so fix these first.
      
      The `filelog` class used to subclass `revlog`, but that was changed back in
      1541e1a8e87d (with most or all of the "lost" attributes being forwarded to the
      embedded `revlog` attribute at that time).  These forwarded references were
      dropped over time, and this command has been broken at least as far back as
      68282a7b29a7 when the `version` field was dropped.  Most of the fixes were as
      simple as calling the accessor for the embedded `revlog` member, but the general
      delta feature detection was a bit more involved- I copied the detection for it
      from `mercurial.revlogutils.debug.debug_revlog()`.
      c371134fef01
    • Matt Harbison's avatar
      typing: add type hints to the `opener` attributes and arguments of revlog · 71fb6e0a7a35
      Matt Harbison authored
      When making revlog and filelog classes visible to pytype, it got confused quite
      a bit in `mercurial/revlogutils/rewrite.py`, thinking it had a plain `Callable`,
      and flagging additional methods on it like `join()` and `rename()`.  I couldn't
      figure out how it reduced to that (and PyCharm flagged `opener` references as
      `Any`), but this makes it happy.  So make this change before making the classes
      visible.
      
      The vfs class hierarchy is a bit wonky (e.g. `filteredvfs` is not a `vfs`), so
      this may need to be revisited with a Protocol class that covers all of the `vfs`
      classes.  But for now, everything works.
      71fb6e0a7a35
    • Matt Harbison's avatar
      remotefilelog: honor the `--format` arg of the `debugindex` command · 438f4fca513e
      Matt Harbison authored
      Flagged by PyCharm while investigating pytype spew.  The other `**opts` above
      are already accessed as str.  I've never used remotefilelog, and don't have a
      repo to test this on, so I'm trusting the nearby code.
      438f4fca513e
Loading