Skip to content

Commit de226c7

Browse files
committed
Format / lint via pre-commit
1 parent 8eedaa6 commit de226c7

16 files changed

+353
-222
lines changed

.pre-commit-config.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v1.4.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
- id: debug-statements
9+
- id: flake8
10+
exclude: ^docs/conf.py
11+
- repo: https://github.com/asottile/pyupgrade
12+
rev: v1.4.0
13+
hooks:
14+
- id: pyupgrade
15+
- repo: https://github.com/asottile/add-trailing-comma
16+
rev: v0.6.4
17+
hooks:
18+
- id: add-trailing-comma

.travis.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ script:
1515
- COVERAGE_PROCESS_START=$PWD/.coveragerc pytest sasstests.py
1616
- coverage combine
1717
- coverage report
18-
- flake8 .
18+
- pre-commit run --all-files --show-diff-on-failure
1919
after_success:
2020
- coveralls
2121
cache:
2222
directories:
2323
- $HOME/.cache/pip
24+
- $HOME/.cache/pre-commit

Makefile

-1
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,3 @@ _sass.so: $(C_OBJECTS) $(CPP_OBJECTS) build2/pysass.o
4141
.PHONY: clean
4242
clean:
4343
rm -rf build2 _sass.so
44-

build_manylinux_wheels.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def main():
4141
'quay.io/pypa/manylinux1_x86_64:latest',
4242
'bash', '-exc',
4343
'{} wheel --verbose --wheel-dir /work --no-deps libsass && '
44-
'auditwheel repair --wheel-dir /dist /work/*.whl'.format(pip)
44+
'auditwheel repair --wheel-dir /dist /work/*.whl'.format(pip),
4545
)
4646
dists = tuple(os.path.join('dist', p) for p in os.listdir('dist'))
4747
return upload.main(('-r', 'pypi', '--skip-existing') + dists)

docs/changes.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ or Visual Studio 2013 Update 4+.
471471
- Follow up the libsass upstream: 3.0 --- See the `release note`__ of LibSass.
472472

473473
- Decent extends support
474-
- Basic Sass Maps Support
474+
- Basic Sass Maps Support
475475
- Better UTF-8 Support
476476
- ``call()`` function
477477
- Better Windows Support
@@ -602,7 +602,7 @@ Released on February 21, 2014.
602602
exist yet, rather than siliently fails.
603603
[:issue:`8`, :issue:`9` by Philipp Volguine]
604604
- Merged recent changes from libsass 1.0.1: `57a2f62--v1.0.1`_.
605-
605+
606606
- Supports `variable arguments`_.
607607
- Supports sourcemaps.
608608

docs/conf.py

+22-12
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@
3030

3131
# Add any Sphinx extension module names here, as strings. They can be extensions
3232
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
33-
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx',
34-
'sphinx.ext.extlinks']
33+
extensions = [
34+
'sphinx.ext.autodoc', 'sphinx.ext.intersphinx',
35+
'sphinx.ext.extlinks',
36+
]
3537

3638
# Add any paths that contain templates here, relative to this directory.
3739
templates_path = ['_templates']
@@ -191,8 +193,10 @@
191193
# Grouping the document tree into LaTeX files. List of tuples
192194
# (source start file, target name, title, author, documentclass [howto/manual]).
193195
latex_documents = [
194-
('index', 'libsass.tex', u'libsass Documentation',
195-
u'Hong Minhee', 'manual'),
196+
(
197+
'index', 'libsass.tex', u'libsass Documentation',
198+
u'Hong Minhee', 'manual',
199+
),
196200
]
197201

198202
# The name of an image file (relative to this directory) to place at the top of
@@ -221,8 +225,10 @@
221225
# One entry per manual page. List of tuples
222226
# (source start file, name, description, authors, manual section).
223227
man_pages = [
224-
('index', 'libsass', u'libsass Documentation',
225-
[u'Hong Minhee'], 1)
228+
(
229+
'index', 'libsass', u'libsass Documentation',
230+
[u'Hong Minhee'], 1,
231+
),
226232
]
227233

228234
# If true, show URL addresses after external links.
@@ -235,9 +241,11 @@
235241
# (source start file, target name, title, author,
236242
# dir menu entry, description, category)
237243
texinfo_documents = [
238-
('index', 'libsass', u'libsass Documentation',
239-
u'Hong Minhee', 'libsass', 'One line description of project.',
240-
'Miscellaneous'),
244+
(
245+
'index', 'libsass', u'libsass Documentation',
246+
u'Hong Minhee', 'libsass', 'One line description of project.',
247+
'Miscellaneous',
248+
),
241249
]
242250

243251
# Documents to append as an appendix to all manuals.
@@ -254,14 +262,16 @@
254262
intersphinx_mapping = {
255263
'python': ('https://docs.python.org/', None),
256264
'setuptools': ('https://setuptools.readthedocs.io/', None),
257-
'flask': ('http://flask.pocoo.org/docs/', None)
265+
'flask': ('http://flask.pocoo.org/docs/', None),
258266
}
259267

260268

261269
extlinks = {
262270
'issue': ('https://github.com/sass/libsass-python/issues/%s', '#'),
263-
'branch': ('https://github.com/sass/libsass-python/compare/master...%s',
264-
''),
271+
'branch': (
272+
'https://github.com/sass/libsass-python/compare/master...%s',
273+
'',
274+
),
265275
'commit': ('https://github.com/sass/libsass-python/commit/%s', ''),
266276
'upcommit': ('https://github.com/sass/libsass/commit/%s', ''),
267277
}

requirements-dev.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-e .
22
coverage
33
coverage-enable-subprocess
4-
flake8>=2.4.0
4+
pre-commit
55
pytest
66
werkzeug>=0.9

sass.py

+38-28
Original file line numberDiff line numberDiff line change
@@ -110,17 +110,19 @@ def from_lambda(cls, name, lambda_):
110110
if PY2: # pragma: no cover
111111
a = inspect.getargspec(lambda_)
112112
varargs, varkw, defaults, kwonlyargs = (
113-
a.varargs, a.keywords, a.defaults, None)
113+
a.varargs, a.keywords, a.defaults, None,
114+
)
114115
else: # pragma: no cover
115116
a = inspect.getfullargspec(lambda_)
116117
varargs, varkw, defaults, kwonlyargs = (
117-
a.varargs, a.varkw, a.defaults, a.kwonlyargs)
118+
a.varargs, a.varkw, a.defaults, a.kwonlyargs,
119+
)
118120

119121
if varargs or varkw or defaults or kwonlyargs:
120122
raise TypeError(
121-
'functions cannot have starargs or defaults: {0} {1}'.format(
122-
name, lambda_
123-
)
123+
'functions cannot have starargs or defaults: {} {}'.format(
124+
name, lambda_,
125+
),
124126
)
125127
return cls(name, a.args, lambda_)
126128

@@ -157,7 +159,7 @@ def __init__(self, name, arguments, callable_):
157159
@property
158160
def signature(self):
159161
"""Signature string of the function."""
160-
return '{0}({1})'.format(self.name, ', '.join(self.arguments))
162+
return '{}({})'.format(self.name, ', '.join(self.arguments))
161163

162164
def __call__(self, *args, **kwargs):
163165
return self.callable_(*args, **kwargs)
@@ -177,7 +179,7 @@ def _to_importer_result(single_result):
177179
if len(single_result) not in (1, 2, 3):
178180
raise ValueError(
179181
'Expected importer result to be a tuple of length (1, 2, 3) '
180-
'but got {0}: {1!r}'.format(len(single_result), single_result)
182+
'but got {}: {!r}'.format(len(single_result), single_result),
181183
)
182184

183185
def _to_bytes(obj):
@@ -222,7 +224,7 @@ def _raise(e):
222224

223225
def compile_dirname(
224226
search_path, output_path, output_style, source_comments, include_paths,
225-
precision, custom_functions, importers, custom_import_extensions
227+
precision, custom_functions, importers, custom_import_extensions,
226228
):
227229
fs_encoding = sys.getfilesystemencoding() or sys.getdefaultencoding()
228230
for dirpath, _, filenames in os.walk(search_path, onerror=_raise):
@@ -257,10 +259,10 @@ def compile_dirname(
257259
def _check_no_remaining_kwargs(func, kwargs):
258260
if kwargs:
259261
raise TypeError(
260-
'{0}() got unexpected keyword argument(s) {1}'.format(
262+
'{}() got unexpected keyword argument(s) {}'.format(
261263
func.__name__,
262-
', '.join("'{0}'".format(arg) for arg in sorted(kwargs)),
263-
)
264+
', '.join("'{}'".format(arg) for arg in sorted(kwargs)),
265+
),
264266
)
265267

266268

@@ -511,8 +513,10 @@ def my_importer(path):
511513
if not modes:
512514
raise TypeError('choose one at least in ' + and_join(MODES))
513515
elif len(modes) > 1:
514-
raise TypeError(and_join(modes) + ' are exclusive each other; '
515-
'cannot be used at a time')
516+
raise TypeError(
517+
and_join(modes) + ' are exclusive each other; '
518+
'cannot be used at a time',
519+
)
516520
precision = kwargs.pop('precision', 5)
517521
output_style = kwargs.pop('output_style', 'nested')
518522
if not isinstance(output_style, string_types):
@@ -521,29 +525,33 @@ def my_importer(path):
521525
try:
522526
output_style = OUTPUT_STYLES[output_style]
523527
except KeyError:
524-
raise CompileError('{0} is unsupported output_style; choose one of {1}'
528+
raise CompileError('{} is unsupported output_style; choose one of {}'
525529
''.format(output_style, and_join(OUTPUT_STYLES)))
526530
source_comments = kwargs.pop('source_comments', False)
527531
if source_comments in SOURCE_COMMENTS:
528532
if source_comments == 'none':
529-
deprecation_message = ('you can simply pass False to '
530-
"source_comments instead of 'none'")
533+
deprecation_message = (
534+
'you can simply pass False to '
535+
"source_comments instead of 'none'"
536+
)
531537
source_comments = False
532538
elif source_comments in ('line_numbers', 'default'):
533539
deprecation_message = ('you can simply pass True to '
534540
"source_comments instead of " +
535541
repr(source_comments))
536542
source_comments = True
537543
else:
538-
deprecation_message = ("you don't have to pass 'map' to "
539-
'source_comments but just need to '
540-
'specify source_map_filename')
544+
deprecation_message = (
545+
"you don't have to pass 'map' to "
546+
'source_comments but just need to '
547+
'specify source_map_filename'
548+
)
541549
source_comments = False
542550
warnings.warn(
543551
"values like 'none', 'line_numbers', and 'map' for "
544552
'the source_comments parameter are deprecated; ' +
545553
deprecation_message,
546-
DeprecationWarning
554+
DeprecationWarning,
547555
)
548556
if not isinstance(source_comments, bool):
549557
raise TypeError('source_comments must be bool, not ' +
@@ -559,7 +567,7 @@ def _get_file_arg(key):
559567
if ret and 'filename' not in modes:
560568
raise CompileError(
561569
'{} is only available with filename= keyword argument since '
562-
'has to be aware of it'.format(key)
570+
'has to be aware of it'.format(key),
563571
)
564572
return ret
565573

@@ -591,14 +599,14 @@ def _get_file_arg(key):
591599
'- a set/sequence of {0.__module__}.{0.__name__} objects,\n'
592600
'- a mapping of function name strings to lambda functions,\n'
593601
'- a set/sequence of named functions,\n'
594-
'not {1!r}'.format(SassFunction, custom_functions)
602+
'not {1!r}'.format(SassFunction, custom_functions),
595603
)
596604

597605
_custom_exts = kwargs.pop('custom_import_extensions', []) or []
598606
if not isinstance(_custom_exts, (list, tuple)):
599607
raise TypeError(
600608
'custom_import_extensions must be a list of strings '
601-
'not {}'.format(type(_custom_exts))
609+
'not {}'.format(type(_custom_exts)),
602610
)
603611
custom_import_extensions = [ext.encode('utf-8') for ext in _custom_exts]
604612

@@ -624,7 +632,7 @@ def _get_file_arg(key):
624632
if not isinstance(filename, string_types):
625633
raise TypeError('filename must be a string, not ' + repr(filename))
626634
elif not os.path.isfile(filename):
627-
raise IOError('{0!r} seems not a file'.format(filename))
635+
raise IOError('{!r} seems not a file'.format(filename))
628636
elif isinstance(filename, text_type):
629637
filename = filename.encode(fs_encoding)
630638
_check_no_remaining_kwargs(compile, kwargs)
@@ -643,13 +651,15 @@ def _get_file_arg(key):
643651
try:
644652
search_path, output_path = kwargs.pop('dirname')
645653
except ValueError:
646-
raise ValueError('dirname must be a pair of (source_dir, '
647-
'output_dir)')
654+
raise ValueError(
655+
'dirname must be a pair of (source_dir, '
656+
'output_dir)',
657+
)
648658
_check_no_remaining_kwargs(compile, kwargs)
649659
s, v = compile_dirname(
650660
search_path, output_path, output_style, source_comments,
651661
include_paths, precision, custom_functions, importers,
652-
custom_import_extensions
662+
custom_import_extensions,
653663
)
654664
if s:
655665
return
@@ -777,7 +787,7 @@ def __len__(self):
777787
# Our interface
778788

779789
def __repr__(self):
780-
return '{0}({1})'.format(type(self).__name__, frozenset(self.items()))
790+
return '{}({})'.format(type(self).__name__, frozenset(self.items()))
781791

782792
def __hash__(self):
783793
return self._hash

0 commit comments

Comments
 (0)