diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -72,6 +72,15 @@ stringutil, ) +if not globals(): + from typing import ( + Any, + Dict, + ) + + for t in (Any, Dict): + assert t + table = {} table.update(debugcommandsmod.command._table) @@ -1108,7 +1117,14 @@ finally: state[b'current'] = [node] hbisect.save_state(repo, state) - hbisect.printresult(ui, repo, state, displayer, nodes, bgood) + hbisect.printresult( + ui, + repo, + state, + displayer, + nodes, + bgood, # pytype: disable=name-error + ) return hbisect.checkstate(state) @@ -2970,7 +2986,7 @@ if opts.get(b'base'): basectx = scmutil.revsingle(repo, opts[b'base'], None) # a dict of data to be stored in state file - statedata = {} + statedata = {} # type: Dict[bytes, Any] # list of new nodes created by ongoing graft statedata[b'newnodes'] = [] @@ -3240,7 +3256,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) + l = statedata[b'newnodes'] + l.append(node) # pytype: disable=attribute-error # remove state when we complete successfully if not opts.get(b'dry_run'): @@ -4728,7 +4745,11 @@ if opts.get(b'copies'): endrev = None if revs: - endrev = revs.max() + 1 + # If we're here, we know revs is a smartset.baseset + # because we're not possibly in the linerange mode. Sadly, + # pytype isn't convinced, so we have to suppress the + # warning about list not having a max() method. + endrev = revs.max() + 1 # pytype: disable=attribute-error getcopies = scmutil.getcopiesfn(repo, endrev=endrev) ui.pager(b'log') @@ -7178,11 +7199,13 @@ t = [] if incoming: t.append(_(b'1 or more incoming')) - o = outgoing.missing + o = outgoing.missing # pytype: disable=attribute-error if o: t.append(_(b'%d outgoing') % len(o)) other = dother or sother - if b'bookmarks' in other.listkeys(b'namespaces'): + if b'bookmarks' in other.listkeys( # pytype: disable=attribute-error + b'namespaces' + ): counts = bookmarks.summary(repo, other) if counts[0] > 0: t.append(_(b'%d incoming bookmarks') % counts[0])