Don't add space between None and a dot.
Closes #487
diff --git a/CHANGELOG b/CHANGELOG
index be1ffb1..e190fa6 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,10 @@
# All notable changes to this project will be documented in this file.
# This project adheres to [Semantic Versioning](http://semver.org/).
+## [0.20.1] UNRELEASED
+### Fixed
+- Don't treat 'None' as a keyword if calling a function on it, like '__ne__()'.
+
## [0.20.0] 2017-11-14
### Added
- Improve splitting of comprehensions and generators. Add
diff --git a/yapf/yapflib/unwrapped_line.py b/yapf/yapflib/unwrapped_line.py
index 21a4cc7..781f6f3 100644
--- a/yapf/yapflib/unwrapped_line.py
+++ b/yapf/yapflib/unwrapped_line.py
@@ -317,7 +317,7 @@
return False
if left.is_keyword and rval == '.' or lval == '.' and right.is_keyword:
# Add space between keywords and dots.
- return True
+ return lval != 'None'
if lval == '.' or rval == '.':
# Don't place spaces between dots.
return False
diff --git a/yapftests/reformatter_python3_test.py b/yapftests/reformatter_python3_test.py
index c6a3e99..f9ce857 100644
--- a/yapftests/reformatter_python3_test.py
+++ b/yapftests/reformatter_python3_test.py
@@ -181,6 +181,13 @@
uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+ def testNoneKeyword(self):
+ code = """\
+None.__ne__()
+"""
+ uwlines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+
def testAsyncWithPrecedingComment(self):
if sys.version_info[1] < 5:
return