changeset 46808:b26f9560f40d

commands: necessary annotations and assertions to pass pytype This is a slightly less forceful incarnation of D7384, where pytype can be appeased with some assertions rather than disabling warnings. Differential Revision: https://phab.mercurial-scm.org/D10236
author Matt Harbison <matt_harbison@yahoo.com>
date Fri, 19 Mar 2021 00:28:30 -0400
parents 2c0e35f6957a
children 56d441256e82
files mercurial/commands.py
diffstat 1 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Thu Mar 18 23:41:00 2021 -0400
+++ b/mercurial/commands.py	Fri Mar 19 00:28:30 2021 -0400
@@ -76,6 +76,12 @@
     stringutil,
 )
 
+if pycompat.TYPE_CHECKING:
+    from typing import (
+        List,
+    )
+
+
 table = {}
 table.update(debugcommandsmod.command._table)
 
@@ -3295,7 +3301,8 @@
                 )
             # checking that newnodes exist because old state files won't have it
             elif statedata.get(b'newnodes') is not None:
-                statedata[b'newnodes'].append(node)
+                nn = statedata[b'newnodes']  # type: List[bytes]
+                nn.append(node)
 
     # remove state when we complete successfully
     if not opts.get(b'dry_run'):
@@ -7268,6 +7275,12 @@
         dest = dbranch = dother = outgoing = None
 
     if opts.get(b'remote'):
+        # Help pytype.  --remote sets both `needsincoming` and `needsoutgoing`.
+        # The former always sets `sother` (or raises an exception if it can't);
+        # the latter always sets `outgoing`.
+        assert sother is not None
+        assert outgoing is not None
+
         t = []
         if incoming:
             t.append(_(b'1 or more incoming'))