Patchwork D11916: pytype: stop excluding copies.py

login
register
mail settings
Submitter phabricator
Date Dec. 14, 2021, 9:11 p.m.
Message ID <differential-rev-PHID-DREV-c52qsew34dmdvxizmtw5-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50243/
State New
Headers show

Comments

phabricator - Dec. 14, 2021, 9:11 p.m.
mharbison72 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/copies.py
  tests/test-check-pytype.t

CHANGE DETAILS




To: mharbison72, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/tests/test-check-pytype.t b/tests/test-check-pytype.t
--- a/tests/test-check-pytype.t
+++ b/tests/test-check-pytype.t
@@ -13,7 +13,6 @@ 
 mercurial/chgserver.py        # [attribute-error]
 mercurial/cmdutil.py          # No attribute 'markcopied' on mercurial.context.filectx [attribute-error]
 mercurial/context.py          # many [attribute-error]
-mercurial/copies.py           # No attribute 'items' on None [attribute-error]
 mercurial/crecord.py          # tons of [attribute-error], [module-attr]
 mercurial/debugcommands.py    # [wrong-arg-types]
 mercurial/dispatch.py         # initstdio: No attribute ... on TextIO [attribute-error]
@@ -57,7 +56,6 @@ 
   >    -x mercurial/chgserver.py \
   >    -x mercurial/cmdutil.py \
   >    -x mercurial/context.py \
-  >    -x mercurial/copies.py \
   >    -x mercurial/crecord.py \
   >    -x mercurial/debugcommands.py \
   >    -x mercurial/dispatch.py \
diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -448,7 +448,11 @@ 
 
         # filter out internal details and return a {dest: source mapping}
         final_copies = {}
-        for dest, (tt, source) in all_copies[targetrev].items():
+
+        targetrev_items = all_copies[targetrev]
+        assert targetrev_items is not None  # help pytype
+
+        for dest, (tt, source) in targetrev_items.items():
             if source is not None:
                 final_copies[dest] = source
     if not alwaysmatch: