mirror of https://github.com/zulip/zulip.git
mypy: Assert non-Noneness.
Convince mypy that an object cannot be None by using an assert.
This commit is contained in:
parent
13ee26019f
commit
b805e0ca10
|
@ -55,6 +55,7 @@ def check_pyflakes(options, by_lang):
|
|||
|
||||
# pyflakes writes some output (like syntax errors) to stderr. :/
|
||||
for pipe in (pyflakes.stdout, pyflakes.stderr):
|
||||
assert(pipe is not None) # convince mypy that pipe cannot be None
|
||||
for ln in pipe:
|
||||
if options.full or not (
|
||||
('imported but unused' in ln or
|
||||
|
@ -142,6 +143,7 @@ def check_pep8(files):
|
|||
['pycodestyle'] + files + ['--ignore={rules}'.format(rules=','.join(ignored_rules))],
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
|
||||
for pipe in (pep8.stdout, pep8.stderr):
|
||||
assert(pipe is not None) # convince mypy that pipe cannot be None
|
||||
for ln in pipe:
|
||||
sys.stdout.write(ln)
|
||||
failed = True
|
||||
|
|
|
@ -22,6 +22,7 @@ with tarfile.open(fileobj=stdin, mode='r|*') as in_tar, \
|
|||
for info in in_tar:
|
||||
if info.isfile():
|
||||
file = in_tar.extractfile(info)
|
||||
assert(file is not None) # this assert convinces mypy that it's okay to do file.read()
|
||||
data = file.read()
|
||||
if data.startswith(old_shebang_bytes + b' ') or data.startswith(old_shebang_bytes + b'\n'):
|
||||
print('editing', info.name, file=sys.stderr)
|
||||
|
|
Loading…
Reference in New Issue