comparison mercurial/dispatch.py @ 43706:ac8fd215a776

dispatch: add some assertions to give pytype a helping hand Differential Revision: https://phab.mercurial-scm.org/D7409
author Augie Fackler <augie@google.com>
date Thu, 14 Nov 2019 15:49:21 -0500
parents 9f70512ae2cf
children be8552f25cab
comparison
equal deleted inserted replaced
43705:1ea33dff7841 43706:ac8fd215a776
113 err = e 113 err = e
114 status = -1 114 status = -1
115 115
116 # In all cases we try to flush stdio streams. 116 # In all cases we try to flush stdio streams.
117 if util.safehasattr(req.ui, b'fout'): 117 if util.safehasattr(req.ui, b'fout'):
118 assert req.ui is not None # help pytype
119 assert req.ui.fout is not None # help pytype
118 try: 120 try:
119 req.ui.fout.flush() 121 req.ui.fout.flush()
120 except IOError as e: 122 except IOError as e:
121 err = e 123 err = e
122 status = -1 124 status = -1
123 125
124 if util.safehasattr(req.ui, b'ferr'): 126 if util.safehasattr(req.ui, b'ferr'):
127 assert req.ui is not None # help pytype
128 assert req.ui.ferr is not None # help pytype
125 try: 129 try:
126 if err is not None and err.errno != errno.EPIPE: 130 if err is not None and err.errno != errno.EPIPE:
127 req.ui.ferr.write( 131 req.ui.ferr.write(
128 b'abort: %s\n' % encoding.strtolocal(err.strerror) 132 b'abort: %s\n' % encoding.strtolocal(err.strerror)
129 ) 133 )
1106 elif not cmd: 1110 elif not cmd:
1107 return commands.help_(ui, b'shortlist') 1111 return commands.help_(ui, b'shortlist')
1108 1112
1109 repo = None 1113 repo = None
1110 cmdpats = args[:] 1114 cmdpats = args[:]
1115 assert func is not None # help out pytype
1111 if not func.norepo: 1116 if not func.norepo:
1112 # use the repo from the request only if we don't have -R 1117 # use the repo from the request only if we don't have -R
1113 if not rpath and not cwd: 1118 if not rpath and not cwd:
1114 repo = req.repo 1119 repo = req.repo
1115 1120