Skip to content
This repository was archived by the owner on Oct 24, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v1.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: debug-statements
- id: flake8
exclude: ^docs/conf.py
- repo: https://github.com/asottile/pyupgrade
rev: v1.4.0
hooks:
- id: pyupgrade
- repo: https://github.com/asottile/add-trailing-comma
rev: v0.6.4
hooks:
- id: add-trailing-comma
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ script:
- COVERAGE_PROCESS_START=$PWD/.coveragerc pytest sasstests.py
- coverage combine
- coverage report
- flake8 .
- pre-commit run --all-files --show-diff-on-failure
after_success:
- coveralls
cache:
directories:
- $HOME/.cache/pip
- $HOME/.cache/pre-commit
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,3 @@ _sass.so: $(C_OBJECTS) $(CPP_OBJECTS) build2/pysass.o
.PHONY: clean
clean:
rm -rf build2 _sass.so

2 changes: 1 addition & 1 deletion build_manylinux_wheels.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def main():
'quay.io/pypa/manylinux1_x86_64:latest',
'bash', '-exc',
'{} wheel --verbose --wheel-dir /work --no-deps libsass && '
'auditwheel repair --wheel-dir /dist /work/*.whl'.format(pip)
'auditwheel repair --wheel-dir /dist /work/*.whl'.format(pip),
)
dists = tuple(os.path.join('dist', p) for p in os.listdir('dist'))
return upload.main(('-r', 'pypi', '--skip-existing') + dists)
Expand Down
4 changes: 2 additions & 2 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ or Visual Studio 2013 Update 4+.
- Follow up the libsass upstream: 3.0 --- See the `release note`__ of LibSass.

- Decent extends support
- Basic Sass Maps Support
- Basic Sass Maps Support
- Better UTF-8 Support
- ``call()`` function
- Better Windows Support
Expand Down Expand Up @@ -602,7 +602,7 @@ Released on February 21, 2014.
exist yet, rather than siliently fails.
[:issue:`8`, :issue:`9` by Philipp Volguine]
- Merged recent changes from libsass 1.0.1: `57a2f62--v1.0.1`_.

- Supports `variable arguments`_.
- Supports sourcemaps.

Expand Down
34 changes: 22 additions & 12 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@

# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx',
'sphinx.ext.extlinks']
extensions = [
'sphinx.ext.autodoc', 'sphinx.ext.intersphinx',
'sphinx.ext.extlinks',
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
Expand Down Expand Up @@ -191,8 +193,10 @@
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'libsass.tex', u'libsass Documentation',
u'Hong Minhee', 'manual'),
(
'index', 'libsass.tex', u'libsass Documentation',
u'Hong Minhee', 'manual',
),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -221,8 +225,10 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'libsass', u'libsass Documentation',
[u'Hong Minhee'], 1)
(
'index', 'libsass', u'libsass Documentation',
[u'Hong Minhee'], 1,
),
]

# If true, show URL addresses after external links.
Expand All @@ -235,9 +241,11 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'libsass', u'libsass Documentation',
u'Hong Minhee', 'libsass', 'One line description of project.',
'Miscellaneous'),
(
'index', 'libsass', u'libsass Documentation',
u'Hong Minhee', 'libsass', 'One line description of project.',
'Miscellaneous',
),
]

# Documents to append as an appendix to all manuals.
Expand All @@ -254,14 +262,16 @@
intersphinx_mapping = {
'python': ('https://docs.python.org/', None),
'setuptools': ('https://setuptools.readthedocs.io/', None),
'flask': ('http://flask.pocoo.org/docs/', None)
'flask': ('http://flask.pocoo.org/docs/', None),
}


extlinks = {
'issue': ('https://github.com/sass/libsass-python/issues/%s', '#'),
'branch': ('https://github.com/sass/libsass-python/compare/master...%s',
''),
'branch': (
'https://github.com/sass/libsass-python/compare/master...%s',
'',
),
'commit': ('https://github.com/sass/libsass-python/commit/%s', ''),
'upcommit': ('https://github.com/sass/libsass/commit/%s', ''),
}
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-e .
coverage
coverage-enable-subprocess
flake8>=2.4.0
pre-commit
pytest
werkzeug>=0.9
66 changes: 38 additions & 28 deletions sass.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,19 @@ def from_lambda(cls, name, lambda_):
if PY2: # pragma: no cover
a = inspect.getargspec(lambda_)
varargs, varkw, defaults, kwonlyargs = (
a.varargs, a.keywords, a.defaults, None)
a.varargs, a.keywords, a.defaults, None,
)
else: # pragma: no cover
a = inspect.getfullargspec(lambda_)
varargs, varkw, defaults, kwonlyargs = (
a.varargs, a.varkw, a.defaults, a.kwonlyargs)
a.varargs, a.varkw, a.defaults, a.kwonlyargs,
)

if varargs or varkw or defaults or kwonlyargs:
raise TypeError(
'functions cannot have starargs or defaults: {0} {1}'.format(
name, lambda_
)
'functions cannot have starargs or defaults: {} {}'.format(
name, lambda_,
),
)
return cls(name, a.args, lambda_)

Expand Down Expand Up @@ -157,7 +159,7 @@ def __init__(self, name, arguments, callable_):
@property
def signature(self):
"""Signature string of the function."""
return '{0}({1})'.format(self.name, ', '.join(self.arguments))
return '{}({})'.format(self.name, ', '.join(self.arguments))

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

def _to_bytes(obj):
Expand Down Expand Up @@ -222,7 +224,7 @@ def _raise(e):

def compile_dirname(
search_path, output_path, output_style, source_comments, include_paths,
precision, custom_functions, importers, custom_import_extensions
precision, custom_functions, importers, custom_import_extensions,
):
fs_encoding = sys.getfilesystemencoding() or sys.getdefaultencoding()
for dirpath, _, filenames in os.walk(search_path, onerror=_raise):
Expand Down Expand Up @@ -257,10 +259,10 @@ def compile_dirname(
def _check_no_remaining_kwargs(func, kwargs):
if kwargs:
raise TypeError(
'{0}() got unexpected keyword argument(s) {1}'.format(
'{}() got unexpected keyword argument(s) {}'.format(
func.__name__,
', '.join("'{0}'".format(arg) for arg in sorted(kwargs)),
)
', '.join("'{}'".format(arg) for arg in sorted(kwargs)),
),
)


Expand Down Expand Up @@ -511,8 +513,10 @@ def my_importer(path):
if not modes:
raise TypeError('choose one at least in ' + and_join(MODES))
elif len(modes) > 1:
raise TypeError(and_join(modes) + ' are exclusive each other; '
'cannot be used at a time')
raise TypeError(
and_join(modes) + ' are exclusive each other; '
'cannot be used at a time',
)
precision = kwargs.pop('precision', 5)
output_style = kwargs.pop('output_style', 'nested')
if not isinstance(output_style, string_types):
Expand All @@ -521,29 +525,33 @@ def my_importer(path):
try:
output_style = OUTPUT_STYLES[output_style]
except KeyError:
raise CompileError('{0} is unsupported output_style; choose one of {1}'
raise CompileError('{} is unsupported output_style; choose one of {}'
''.format(output_style, and_join(OUTPUT_STYLES)))
source_comments = kwargs.pop('source_comments', False)
if source_comments in SOURCE_COMMENTS:
if source_comments == 'none':
deprecation_message = ('you can simply pass False to '
"source_comments instead of 'none'")
deprecation_message = (
'you can simply pass False to '
"source_comments instead of 'none'"
)
source_comments = False
elif source_comments in ('line_numbers', 'default'):
deprecation_message = ('you can simply pass True to '
"source_comments instead of " +
repr(source_comments))
source_comments = True
else:
deprecation_message = ("you don't have to pass 'map' to "
'source_comments but just need to '
'specify source_map_filename')
deprecation_message = (
"you don't have to pass 'map' to "
'source_comments but just need to '
'specify source_map_filename'
)
source_comments = False
warnings.warn(
"values like 'none', 'line_numbers', and 'map' for "
'the source_comments parameter are deprecated; ' +
deprecation_message,
DeprecationWarning
DeprecationWarning,
)
if not isinstance(source_comments, bool):
raise TypeError('source_comments must be bool, not ' +
Expand All @@ -559,7 +567,7 @@ def _get_file_arg(key):
if ret and 'filename' not in modes:
raise CompileError(
'{} is only available with filename= keyword argument since '
'has to be aware of it'.format(key)
'has to be aware of it'.format(key),
)
return ret

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

_custom_exts = kwargs.pop('custom_import_extensions', []) or []
if not isinstance(_custom_exts, (list, tuple)):
raise TypeError(
'custom_import_extensions must be a list of strings '
'not {}'.format(type(_custom_exts))
'not {}'.format(type(_custom_exts)),
)
custom_import_extensions = [ext.encode('utf-8') for ext in _custom_exts]

Expand All @@ -624,7 +632,7 @@ def _get_file_arg(key):
if not isinstance(filename, string_types):
raise TypeError('filename must be a string, not ' + repr(filename))
elif not os.path.isfile(filename):
raise IOError('{0!r} seems not a file'.format(filename))
raise IOError('{!r} seems not a file'.format(filename))
elif isinstance(filename, text_type):
filename = filename.encode(fs_encoding)
_check_no_remaining_kwargs(compile, kwargs)
Expand All @@ -643,13 +651,15 @@ def _get_file_arg(key):
try:
search_path, output_path = kwargs.pop('dirname')
except ValueError:
raise ValueError('dirname must be a pair of (source_dir, '
'output_dir)')
raise ValueError(
'dirname must be a pair of (source_dir, '
'output_dir)',
)
_check_no_remaining_kwargs(compile, kwargs)
s, v = compile_dirname(
search_path, output_path, output_style, source_comments,
include_paths, precision, custom_functions, importers,
custom_import_extensions
custom_import_extensions,
)
if s:
return
Expand Down Expand Up @@ -777,7 +787,7 @@ def __len__(self):
# Our interface

def __repr__(self):
return '{0}({1})'.format(type(self).__name__, frozenset(self.items()))
return '{}({})'.format(type(self).__name__, frozenset(self.items()))

def __hash__(self):
return self._hash
Expand Down
Loading