Skip to content
This repository was archived by the owner on Oct 24, 2025. It is now read-only.

Commit c54f786

Browse files
committed
Follow PEP 8 and run flake8 on CI & tox
1 parent 6bf443e commit c54f786

File tree

9 files changed

+46
-28
lines changed

9 files changed

+46
-28
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ python:
1111
- 3.3
1212
- 3.4
1313
install:
14-
- pip install -e . "Werkzeug >= 0.9" coverage coveralls
14+
- pip install -e . "flake8 >= 2.4.0" "Werkzeug >= 0.9" coverage coveralls
1515
script:
1616
- coverage run --source sass,sassc,sassutils setup.py test
17+
- flake8 .
1718
after_success:
1819
- coveralls

sass.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
1212
"""
1313
from __future__ import absolute_import
14+
1415
import collections
1516
import inspect
1617
from io import open
@@ -432,7 +433,7 @@ def func_name(a, b):
432433
elif isinstance(custom_functions, (collections.Set, collections.Sequence)):
433434
custom_functions = [
434435
func if isinstance(func, SassFunction)
435-
else SassFunction.from_named_function(func)
436+
else SassFunction.from_named_function(func)
436437
for func in custom_functions
437438
]
438439
else:

sassc.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,10 @@ def main(argv=sys.argv, stdout=sys.stdout, stderr=sys.stderr):
8787
parser.add_option('-w', '--watch', action='store_true',
8888
help='Watch file for changes. Requires the second '
8989
'argument (output css filename).')
90-
parser.add_option('-p', '--precision', action='store', type="int", default=5,
91-
help='Set the precision for numbers. [default: %default]')
90+
parser.add_option(
91+
'-p', '--precision', action='store', type='int', default=5,
92+
help='Set the precision for numbers. [default: %default]'
93+
)
9294
options, args = parser.parse_args(argv[1:])
9395
error = functools.partial(print,
9496
parser.get_prog_name() + ': error:',

sasstests.py

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ def normalize_path(path):
5858
'sources': ['test/a.scss'],
5959
'sourcesContent': [],
6060
'names': [],
61-
'mappings': ';AAKA,IAAI,CAAC;EAHH,gBAAgB,EAAE,KAAM,GAGpB;;EAEJ,IAAI,CAAC,CAAC,CAAJ;IACA,KAAK,EAAE,IAAK,GADX',
61+
'mappings': ';AAKA,IAAI,CAAC;EAHH,gBAAgB,EAAE,KAAM,GAGpB;;'
62+
'EAEJ,IAAI,CAAC,CAAC,CAAJ;IACA,KAAK,EAAE,IAAK,GADX',
6263
}
6364

6465
B_EXPECTED_CSS = '''\
@@ -458,7 +459,8 @@ def test_build_one(self):
458459
'sources': ['../test/b.scss'],
459460
'sourcesContent': [],
460461
'names': [],
461-
'mappings': ';AACE,CAAC,CAAC,CAAC,CAAD;EACA,SAAS,EAAE,IAAK,GADf',
462+
'mappings': ';AACE,CAAC,CAAC,CAAC,CAAD;'
463+
'EACA,SAAS,EAAE,IAAK,GADf',
462464
},
463465
os.path.join(d, 'css', 'b.scss.css.map')
464466
)
@@ -476,7 +478,9 @@ def test_build_one(self):
476478
'sources': ['../test/d.scss'],
477479
'sourcesContent': [],
478480
'names': [],
479-
'mappings': ';;AAKA,IAAI,CAAC;EAHH,gBAAgB,EAAE,KAAM,GAGpB;;EAEJ,IAAI,CAAC,CAAC,CAAJ;IACA,IAAI,EAAE,0BAA2B,GADhC',
481+
'mappings': ';;AAKA,IAAI,CAAC;EAHH,gBAAgB,EAAE,KAAM,GAGpB;'
482+
';EAEJ,IAAI,CAAC,CAAC,CAAJ'
483+
';IACA,IAAI,EAAE,0BAA2B,GADhC',
480484
},
481485
os.path.join(d, 'css', 'd.scss.css.map')
482486
)
@@ -582,7 +586,7 @@ def test_no_args(self):
582586
self.assertEqual(2, exit_code)
583587
err = self.err.getvalue()
584588
assert err.strip().endswith('error: too few arguments'), \
585-
'actual error message is: ' + repr(err)
589+
'actual error message is: ' + repr(err)
586590
self.assertEqual('', self.out.getvalue())
587591

588592
def test_three_args(self):
@@ -593,7 +597,7 @@ def test_three_args(self):
593597
self.assertEqual(2, exit_code)
594598
err = self.err.getvalue()
595599
assert err.strip().endswith('error: too many arguments'), \
596-
'actual error message is: ' + repr(err)
600+
'actual error message is: ' + repr(err)
597601
self.assertEqual('', self.out.getvalue())
598602

599603
def test_sassc_stdout(self):
@@ -640,7 +644,7 @@ def test_sassc_source_map_without_css_filename(self):
640644
assert err.strip().endswith('error: -m/-g/--sourcemap requires '
641645
'the second argument, the output css '
642646
'filename.'), \
643-
'actual error message is: ' + repr(err)
647+
'actual error message is: ' + repr(err)
644648
self.assertEqual('', self.out.getvalue())
645649

646650
def test_sassc_sourcemap(self):
@@ -694,8 +698,10 @@ def test_successful(self):
694698
input_dir = os.path.join(tmpdir, 'input')
695699
output_dir = os.path.join(tmpdir, 'output')
696700
os.makedirs(os.path.join(input_dir, 'foo'))
697-
write_file(os.path.join(input_dir, 'f1.scss'), 'a { b { width: 100%; } }')
698-
write_file(os.path.join(input_dir, 'foo/f2.scss'), 'foo { width: 100%; }')
701+
write_file(os.path.join(input_dir, 'f1.scss'),
702+
'a { b { width: 100%; } }')
703+
write_file(os.path.join(input_dir, 'foo/f2.scss'),
704+
'foo { width: 100%; }')
699705
# Make sure we don't compile non-scss files
700706
write_file(os.path.join(input_dir, 'baz.txt'), 'Hello der')
701707

@@ -744,7 +750,9 @@ def test_error(self):
744750
write_file(os.path.join(input_dir, 'bad.scss'), 'a {')
745751

746752
try:
747-
sass.compile(dirname=(input_dir, os.path.join(tmpdir, 'output')))
753+
sass.compile(
754+
dirname=(input_dir, os.path.join(tmpdir, 'output'))
755+
)
748756
assert False, 'Expected to raise'
749757
except sass.CompileError as e:
750758
msg, = e.args
@@ -753,7 +761,8 @@ def test_error(self):
753761
), msg
754762
return
755763
except Exception as e:
756-
assert False, 'Expected to raise CompileError but got {0!r}'.format(e)
764+
assert False, \
765+
'Expected to raise CompileError but got {0!r}'.format(e)
757766

758767

759768
class SassFunctionTest(unittest.TestCase):
@@ -845,10 +854,6 @@ def test_sass_warning_no_conversion(self):
845854
warn = sass.SassWarning(u'error msg')
846855
assert type(warn.msg) is text_type, type(warn.msg)
847856

848-
def test_sass_warning_no_conversion(self):
849-
warn = sass.SassWarning(b'error msg')
850-
assert type(warn.msg) is text_type, type(warn.msg)
851-
852857
def test_sass_error_no_conversion(self):
853858
err = sass.SassError(u'error msg')
854859
assert type(err.msg) is text_type, type(err.msg)
@@ -869,6 +874,7 @@ def returns_warning():
869874
def returns_error():
870875
return sass.SassError('This is an error')
871876

877+
872878
def returns_unknown():
873879
"""Tuples are a not-supported type."""
874880
return 1, 2, 3
@@ -923,7 +929,7 @@ def identity(x):
923929
in C land
924930
925931
"""
926-
import sys
932+
import sys # noqa
927933
return x
928934

929935

sassutils/wsgi.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,9 @@ def __call__(self, environ, start_response):
144144
b'body:before { content: ',
145145
self.quote_css_string(str(e)).encode('utf-8'),
146146
b'; color: maroon; background-color: white',
147-
b'; white-space: pre-wrap; display: block; ',
148-
b'font-family: "Courier New", monospace; user-select: text; }'
147+
b'; white-space: pre-wrap; display: block',
148+
b'; font-family: "Courier New", monospace'
149+
b'; user-select: text; }'
149150
]
150151

151152
def read_file(path):

setup.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[aliases]
22
upload_doc = build_sphinx upload_doc
33
release = sdist upload build_sphinx upload_doc
4+
5+
[flake8]
6+
exclude = build,dist,docs,ez_setup.py

setup.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import distutils.cmd
66
import distutils.log
77
import distutils.sysconfig
8-
import glob
98
import os
109
import os.path
1110
import platform
@@ -94,7 +93,7 @@ def customize_compiler(compiler):
9493
flags.append('-mmacosx-version-min=10.7',)
9594
if tuple(map(int, platform.mac_ver()[0].split('.'))) >= (10, 9):
9695
flags.append(
97-
'-Wno-error=unused-command-line-argument-hard-error-in-future',
96+
'-Wno-error=unused-command-line-argument-hard-error-in-future', # noqa
9897
)
9998
# Dirty workaround to avoid link error...
10099
# Python distutils doesn't provide any way to configure different
@@ -140,7 +139,10 @@ def restore_cencode():
140139
)
141140

142141
install_requires = ['six']
143-
tests_require = ['Werkzeug >= 0.9']
142+
tests_require = [
143+
'flake8 >= 2.4.0',
144+
'Werkzeug >= 0.9'
145+
]
144146

145147

146148
def version(sass_filename='sass.py'):

tox.ini

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
envlist = pypy, py26, py27, py33, py34
33

44
[testenv]
5-
deps = Werkzeug >= 0.9
5+
deps =
6+
flake8 >= 2.4.0
7+
Werkzeug >= 0.9
68
commands =
79
python -c 'from shutil import *; rmtree("build", True)'
810
python -m unittest sasstests
11+
flake8 .

upload_appveyor_builds.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import shutil
1111
import subprocess
1212

13-
from six import PY3
1413
from six.moves.urllib.parse import urljoin
1514
from six.moves.urllib.request import urlopen
1615
from twine.commands.upload import upload
@@ -84,8 +83,8 @@ def download_artifact(artifact, target_dir, overwrite=False):
8483
response = urlopen(artifact['url'])
8584
filename = os.path.basename(artifact['fileName'])
8685
target_path = os.path.join(target_dir, filename)
87-
if (os.path.isfile(target_path) and
88-
os.path.getsize(target_path) == artifact['size']):
86+
if os.path.isfile(target_path) and \
87+
os.path.getsize(target_path) == artifact['size']:
8988
if overwrite:
9089
print(artifact['fileName'], ' already exists; overwrite...')
9190
else:

0 commit comments

Comments
 (0)