Skip to content

Commit 1ca863d

Browse files
Merge pull request #1167 from cclauss/patch-1
Travis CI: Lint Python code with flake8
2 parents 2c512d8 + cbd88e6 commit 1ca863d

File tree

7 files changed

+27
-19
lines changed

7 files changed

+27
-19
lines changed

.travis.yml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
matrix:
33
fast_finish: true
44
include:
5-
- name: Run rust tests
5+
- name: Run Rust tests
66
language: rust
77
rust: stable
88
cache: cargo
@@ -16,7 +16,7 @@ matrix:
1616

1717
# To test the snippets, we use Travis' Python environment (because
1818
# installing rust ourselves is a lot easier than installing Python)
19-
- name: python test snippets
19+
- name: Python test snippets
2020
language: python
2121
python: 3.6
2222
cache:
@@ -28,7 +28,7 @@ matrix:
2828
- CODE_COVERAGE=false
2929
script: tests/.travis-runner.sh
3030

31-
- name: Check rust code style with rustfmt
31+
- name: Check Rust code style with rustfmt
3232
language: rust
3333
rust: stable
3434
cache: cargo
@@ -39,7 +39,7 @@ matrix:
3939
env:
4040
- JOBCACHE=3
4141

42-
- name: Lint code with clippy
42+
- name: Lint Rust code with clippy
4343
language: rust
4444
rust: stable
4545
cache: cargo
@@ -50,7 +50,15 @@ matrix:
5050
env:
5151
- JOBCACHE=8
5252

53-
- name: publish documentation
53+
- name: Lint Python code with flake8
54+
language: python
55+
python: 3.6
56+
cache: pip
57+
env: JOBCACHE=9
58+
install: pip install flake8
59+
script: flake8 . --count --exclude=./.*,./Lib,./vm/Lib --select=E9,F63,F7,F82 --show-source --statistics
60+
61+
- name: Publish documentation
5462
language: rust
5563
rust: stable
5664
cache: cargo
@@ -109,7 +117,7 @@ matrix:
109117
- TRAVIS_RUST_VERSION=nightly
110118
- CODE_COVERAGE=true
111119

112-
- name: test WASM
120+
- name: Test WASM
113121
language: python
114122
python: 3.6
115123
cache:

tests/snippets/bools.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ def __bool__(self):
3434

3535
assert not Falsey()
3636

37-
assert (True or fake)
37+
assert (True or fake) # noqa: F821
3838
assert (False or True)
3939
assert not (False or False)
4040
assert ("thing" or 0) == "thing"
4141

4242
assert (True and True)
43-
assert not (False and fake)
43+
assert not (False and fake) # noqa: F821
4444
assert (True and 5) == 5
4545

4646
# Bools are also ints.

tests/snippets/builtins_module.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
__builtins__.__builtins__
77

88
__builtins__.x = 'new'
9-
assert x == 'new'
9+
assert x == 'new' # noqa: F821
1010

1111
exec('assert "__builtins__" in globals()', dict())
1212
exec('assert __builtins__ == 7', {'__builtins__': 7})
@@ -23,6 +23,6 @@
2323
# __builtins__ is deletable but names are alive
2424
del __builtins__
2525
with assertRaises(NameError):
26-
__builtins__
26+
__builtins__ # noqa: F821
2727

2828
assert print

tests/snippets/delete.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ class MyObject: pass
1414
x = 1
1515
y = 2
1616
del (x, y)
17-
assert_raises(NameError, lambda: x)
18-
assert_raises(NameError, lambda: y)
17+
assert_raises(NameError, lambda: x) # noqa: F821
18+
assert_raises(NameError, lambda: y) # noqa: F821
1919

2020
with assertRaises(NameError):
21-
del y
21+
del y # noqa: F821

tests/snippets/dismod.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
print("\n")
1111

1212
def f():
13-
with g():
13+
with g(): # noqa: F821
1414
try:
1515
for a in {1: 4, 2: 5}:
1616
yield [True and False or True, []]
@@ -21,7 +21,7 @@ def f():
2121

2222
class A(object):
2323
def f():
24-
x += 1
24+
x += 1 # noqa: F821
2525
pass
2626
def g():
2727
for i in range(5):

tests/snippets/test_exec.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
exec("def square(x):\n return x * x\n")
2-
assert 16 == square(4)
2+
assert 16 == square(4) # noqa: F821
33

44
d = {}
55
exec("def square(x):\n return x * x\n", {}, d)
@@ -39,8 +39,8 @@ def f():
3939
g = globals()
4040
g['x'] = 2
4141
exec('x += 2')
42-
assert x == 4
43-
assert g['x'] == x
42+
assert x == 4 # noqa: F821
43+
assert g['x'] == x # noqa: F821
4444

4545
exec("del x")
4646
assert 'x' not in g

tests/snippets/try_exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
class E(Exception):
1717
def __init__(self):
18-
asdf
18+
asdf # noqa: F821
1919

2020
try:
2121
raise E

0 commit comments

Comments
 (0)