Space between ellipses and keywords
Closes #464
diff --git a/CHANGELOG b/CHANGELOG
index fb7a63e..7dbe0a0 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -8,6 +8,8 @@
split before the first argument in a function call.
- Split before the first argument in a function call if the arguments contain a
dictionary that doesn't fit on a single line.
+### Fixed
+- Enforce spaces between ellipses and keywords.
## [0.19.0] 2017-10-14
### Added
diff --git a/README.rst b/README.rst
index 3578e20..ae2bc74 100644
--- a/README.rst
+++ b/README.rst
@@ -90,6 +90,7 @@
usage: yapf [-h] [-v] [-d | -i] [-r | -l START-END] [-e PATTERN]
[--style STYLE] [--style-help] [--no-local-style] [-p]
+ [-vv]
[files [files ...]]
Formatter for Python code.
@@ -113,10 +114,12 @@
.style.yapf or setup.cfg file located in one of the
parent directories of the source file (or current
directory for stdin)
- --style-help show style settings and exit
- --no-local-style don't search for local style definition (.style.yapf)
+ --style-help show style settings and exit; this output can be saved
+ to .style.yapf to make your settings permanent
+ --no-local-style don't search for local style definition
-p, --parallel Run yapf in parallel when formatting multiple files.
Requires concurrent.futures in Python 2.X
+ -vv, --verbose Print out file names while processing
Formatting style
diff --git a/yapf/yapflib/unwrapped_line.py b/yapf/yapflib/unwrapped_line.py
index b27de29..21a4cc7 100644
--- a/yapf/yapflib/unwrapped_line.py
+++ b/yapf/yapflib/unwrapped_line.py
@@ -315,6 +315,9 @@
if lval == '@' and format_token.Subtype.DECORATOR in left.subtypes:
# Decorators shouldn't be separated from the 'at' sign.
return False
+ if left.is_keyword and rval == '.' or lval == '.' and right.is_keyword:
+ # Add space between keywords and dots.
+ return True
if lval == '.' or rval == '.':
# Don't place spaces between dots.
return False
diff --git a/yapftests/reformatter_basic_test.py b/yapftests/reformatter_basic_test.py
index 66ac1b2..843dd8d 100644
--- a/yapftests/reformatter_basic_test.py
+++ b/yapftests/reformatter_basic_test.py
@@ -2201,9 +2201,11 @@
def testEllipses(self):
unformatted_code = textwrap.dedent("""\
X=...
+ Y = X if ... else X
""")
expected_code = textwrap.dedent("""\
X = ...
+ Y = X if ... else X
""")
uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertEqual(expected_code, reformatter.Reformat(uwlines))