Patchwork D11912: pytype: stop excluding changegroup.py

login
register
mail settings
Submitter phabricator
Date Dec. 14, 2021, 9:11 p.m.
Message ID <differential-rev-PHID-DREV-5kbmh4bywx5grncry7cb-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50241/
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
  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]

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/changegroup.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
@@ -10,7 +10,6 @@ 
 probably hiding real problems.
 
 mercurial/bundlerepo.py       # no vfs and ui attrs on bundlerepo
-mercurial/changegroup.py      # mysterious incorrect type detection
 mercurial/chgserver.py        # [attribute-error]
 mercurial/cmdutil.py          # No attribute 'markcopied' on mercurial.context.filectx [attribute-error]
 mercurial/context.py          # many [attribute-error]
@@ -56,7 +55,6 @@ 
 
   $ pytype -V 3.6 --keep-going --jobs auto mercurial \
   >    -x mercurial/bundlerepo.py \
-  >    -x mercurial/changegroup.py \
   >    -x mercurial/chgserver.py \
   >    -x mercurial/cmdutil.py \
   >    -x mercurial/context.py \
diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -354,6 +354,7 @@ 
 
             def onchangelog(cl, rev):
                 ctx = cl.changelogrevision(rev)
+                assert efilesset is not None  # help pytype
                 efilesset.update(ctx.files)
                 repo.register_changeset(rev, ctx)
 
@@ -531,12 +532,13 @@ 
             if added:
                 phases.registernew(repo, tr, targetphase, added)
             if phaseall is not None:
-                if duprevs:
-                    duprevs.extend(added)
+                duplicates = duprevs
+                if duplicates:
+                    duplicates.extend(added)
                 else:
-                    duprevs = added
-                phases.advanceboundary(repo, tr, phaseall, [], revs=duprevs)
-                duprevs = []
+                    duplicates = added
+                phases.advanceboundary(repo, tr, phaseall, [], revs=duplicates)
+                duprevs = duplicates = []
 
             if changesets > 0: