Patchwork D7290: branchmap: pytype is confused about bytestr

login
register
mail settings
Submitter phabricator
Date Nov. 6, 2019, 11:01 p.m.
Message ID <differential-rev-PHID-DREV-4q5dnsurb6fguaz3y7ny-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/42841/
State Superseded
Headers show

Comments

phabricator - Nov. 6, 2019, 11:01 p.m.
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D7290

AFFECTED FILES
  mercurial/branchmap.py

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-devel
phabricator - Nov. 8, 2019, 4:46 p.m.
This revision is now accepted and ready to land.
indygreg added a comment.
indygreg accepted this revision.


  Could you please look into this in more detail? Presumably the type checker isn't seeing that `pycompat.bytestr` will accept anything that can be cast to `str`, which `Exception` can. So this feels like it is either a bug in pytype or a missing annotation somewhere. I'd like to know which.
  
  But the comment draws attention to oddness. (I'm assuming we'll be able to disable most type annotator disables long term once more of the code base is properly type annotated.) So I'm fine landing this.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7290/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7290

To: durin42, #hg-reviewers, indygreg
Cc: indygreg, mercurial-devel

Patch

diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -269,7 +269,13 @@ 
             if repo.ui.debugflag:
                 msg = b'invalid %s: %s\n'
                 repo.ui.debug(
-                    msg % (_branchcachedesc(repo), pycompat.bytestr(inst))
+                    msg
+                    % (
+                        _branchcachedesc(repo),
+                        pycompat.bytestr(
+                            inst  # pytype: disable=wrong-arg-types
+                        ),
+                    )
                 )
             bcache = None