Skip to content

Commit acbe736

Browse files
committed
Run flake8 through CI
1 parent a096f0f commit acbe736

File tree

5 files changed

+29
-15
lines changed

5 files changed

+29
-15
lines changed

.travis.yml

+3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ matrix:
2727
dist: trusty
2828
env:
2929
- DEPS="$LEGACY_DEPS"
30+
- python: 3.7
31+
env:
32+
- TOXENV=flake8
3033

3134
install:
3235
- pip install $DEPS

goto.py

+12-9
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ def __init__(self):
1616
code = (lambda: x if x else y).__code__.co_code
1717
opcode, oparg = struct.unpack_from('BB', code, 2)
1818

19-
# Starting with Python 3.6, the bytecode format has been changed to use
19+
# Starting with Python 3.6, the bytecode format has changed, using
2020
# 16-bit words (8-bit opcode + 8-bit argument) for each instruction,
21-
# as opposed to previously 24-bit (8-bit opcode + 16-bit argument) for
22-
# instructions that expect an argument or just 8-bit for those that don't.
21+
# as opposed to previously 24 bit (8-bit opcode + 16-bit argument)
22+
# for instructions that expect an argument and otherwise 8 bit.
2323
# https://bugs.python.org/issue26647
2424
if dis.opname[opcode] == 'POP_JUMP_IF_FALSE':
2525
self.argument = struct.Struct('B')
2626
self.have_argument = 0
27-
# As of Python 3.6, jump targets are still addressed by their byte
28-
# unit. This, however, is matter to change, so that jump targets,
29-
# in the future, will refer to the code unit (address in bytes / 2).
27+
# As of Python 3.6, jump targets are still addressed by their
28+
# byte unit. This is matter to change, so that jump targets,
29+
# in the future might refer to code units (address in bytes / 2).
3030
# https://bugs.python.org/issue26647
3131
self.jump_unit = 8 // oparg
3232
else:
@@ -155,8 +155,9 @@ def _find_labels_and_gotos(code):
155155
name = code.co_names[oparg1]
156156
if name == 'label':
157157
if oparg2 in labels:
158-
co_name = code.co_names[oparg2]
159-
raise SyntaxError('Ambiguous label {0!r}'.format(co_name))
158+
raise SyntaxError('Ambiguous label {0!r}'.format(
159+
code.co_names[oparg2]
160+
))
160161
labels[oparg2] = (offset1,
161162
offset4,
162163
tuple(block_stack))
@@ -196,7 +197,9 @@ def _patch_code(code):
196197
try:
197198
_, target, target_stack = labels[label]
198199
except KeyError:
199-
raise SyntaxError('Unknown label {0!r}'.format(code.co_names[label]))
200+
raise SyntaxError('Unknown label {0!r}'.format(
201+
code.co_names[label]
202+
))
200203

201204
target_depth = len(target_stack)
202205
if origin_stack[:target_depth] != target_stack:

setup.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
name='goto-statement',
99
version='1.2',
1010
url='https://github.com/snoack/python-goto/',
11-
description='A function decorator, that rewrites the bytecode, to enable goto in Python',
11+
description='A function decorator that rewrites the bytecode, '
12+
'enabling goto in Python',
1213
long_description=long_description,
1314
long_description_content_type='text/markdown',
1415
py_modules=['goto'],

test_goto.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import sys
21
import pytest
32
from goto import with_goto
43

@@ -137,21 +136,21 @@ def func():
137136
try:
138137
rv = None
139138
goto .end
140-
except:
139+
except Exception:
141140
rv = 'except'
142141
finally:
143142
rv = 'finally'
144143
label .end
145144
return rv
146145

147-
assert func() == None
146+
assert func() is None
148147

149148

150149
def test_jump_into_try_block():
151150
def func():
152151
try:
153152
label .block
154-
except:
153+
except Exception:
155154
pass
156155
goto .block
157156

tox.ini

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
[tox]
2-
envlist = py26,py27,py32,py33,py34,py35,py36,py37,pypy,pypy3
2+
envlist = py26,py27,py32,py33,py34,py35,py36,py37,pypy,pypy3,flake8
33
skip_missing_interpreters = true
44

55
[testenv]
66
deps = pytest
77
commands = py.test
88

9+
[flake8]
10+
extend-ignore = F821
11+
12+
[testenv:flake8]
13+
skip_install = true
14+
deps = flake8
15+
commands = flake8
16+
917
[legacy]
1018
deps =
1119
py<1.5

0 commit comments

Comments
 (0)