comparison mercurial/commands.py @ 46809: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 f51ff655d338
children d4ba4d51f85f
comparison
equal deleted inserted replaced
46808:2c0e35f6957a 46809:b26f9560f40d
74 from .utils import ( 74 from .utils import (
75 dateutil, 75 dateutil,
76 stringutil, 76 stringutil,
77 ) 77 )
78 78
79 if pycompat.TYPE_CHECKING:
80 from typing import (
81 List,
82 )
83
84
79 table = {} 85 table = {}
80 table.update(debugcommandsmod.command._table) 86 table.update(debugcommandsmod.command._table)
81 87
82 command = registrar.command(table) 88 command = registrar.command(table)
83 INTENT_READONLY = registrar.INTENT_READONLY 89 INTENT_READONLY = registrar.INTENT_READONLY
3293 _(b'note: graft of %d:%s created no changes to commit\n') 3299 _(b'note: graft of %d:%s created no changes to commit\n')
3294 % (ctx.rev(), ctx) 3300 % (ctx.rev(), ctx)
3295 ) 3301 )
3296 # checking that newnodes exist because old state files won't have it 3302 # checking that newnodes exist because old state files won't have it
3297 elif statedata.get(b'newnodes') is not None: 3303 elif statedata.get(b'newnodes') is not None:
3298 statedata[b'newnodes'].append(node) 3304 nn = statedata[b'newnodes'] # type: List[bytes]
3305 nn.append(node)
3299 3306
3300 # remove state when we complete successfully 3307 # remove state when we complete successfully
3301 if not opts.get(b'dry_run'): 3308 if not opts.get(b'dry_run'):
3302 graftstate.delete() 3309 graftstate.delete()
3303 3310
7266 dest, dbranch, dother, outgoing = getoutgoing() 7273 dest, dbranch, dother, outgoing = getoutgoing()
7267 else: 7274 else:
7268 dest = dbranch = dother = outgoing = None 7275 dest = dbranch = dother = outgoing = None
7269 7276
7270 if opts.get(b'remote'): 7277 if opts.get(b'remote'):
7278 # Help pytype. --remote sets both `needsincoming` and `needsoutgoing`.
7279 # The former always sets `sother` (or raises an exception if it can't);
7280 # the latter always sets `outgoing`.
7281 assert sother is not None
7282 assert outgoing is not None
7283
7271 t = [] 7284 t = []
7272 if incoming: 7285 if incoming:
7273 t.append(_(b'1 or more incoming')) 7286 t.append(_(b'1 or more incoming'))
7274 o = outgoing.missing 7287 o = outgoing.missing
7275 if o: 7288 if o: