Bump version to v0.21.0

pull/558/head
Bill Wendling 5 years ago
parent 52ca45ae77
commit c873f37236
  1. 2
      CHANGELOG
  2. 2
      HACKING.rst
  3. 2
      yapf/__init__.py
  4. 11
      yapf/yapflib/format_token.py
  5. 2
      yapf/yapflib/style.py
  6. 16
      yapftests/format_token_test.py
  7. 4
      yapftests/style_test.py

@ -2,7 +2,7 @@
# All notable changes to this project will be documented in this file.
# This project adheres to [Semantic Versioning](http://semver.org/).
## [0.20.3] UNRELEASED
## [0.21.0] 2018-03-18
### Added
- Introduce a new option of formatting multiline literals. Add
`SPLIT_BEFORE_CLOSING_BRACKET` knob to control whether closing bracket should

@ -13,7 +13,7 @@ Releasing a new version
-----------------------
* Run tests: python setup.py test
[don't forget to run with Python 2.7 and 3.4]
[don't forget to run with Python 2.7 and 3.6]
* Bump version in yapf/__init__.py

@ -38,7 +38,7 @@ from yapf.yapflib import py3compat
from yapf.yapflib import style
from yapf.yapflib import yapf_api
__version__ = '0.20.2'
__version__ = '0.21.0'
def main(argv):

@ -300,13 +300,14 @@ class FormatToken(object):
@property
@py3compat.lru_cache()
def is_multiline_string(self):
"""A multiline string."""
if py3compat.PY3:
prefix = "("
prefix += "r|u|R|U|f|F|fr|Fr|fR|FR|rf|rF|Rf|RF" # strings
prefix += "|b|B|br|Br|bR|BR|rb|rB|Rb|RB" # bytes
prefix += ")?"
prefix = '('
prefix += 'r|u|R|U|f|F|fr|Fr|fR|FR|rf|rF|Rf|RF' # strings
prefix += '|b|B|br|Br|bR|BR|rb|rB|Rb|RB' # bytes
prefix += ')?'
else:
prefix = "[uUbB]?[rR]?"
prefix = '[uUbB]?[rR]?'
regex = r'^{prefix}(?P<delim>"""|\'\'\').*(?P=delim)$'.format(prefix=prefix)
return (self.is_string and

@ -371,7 +371,7 @@ def _ContinuationAlignStyleStringConverter(s):
if s:
r = s.upper()
if r not in accepted_styles:
raise ValueError("unknown continuation align style: %r" % (s,))
raise ValueError('unknown continuation align style: %r' % (s,))
else:
r = accepted_styles[0]
return r

@ -42,10 +42,10 @@ class TabbedContinuationAlignPaddingTest(unittest.TestCase):
self.assertEqual(pad, '')
pad = format_token._TabbedContinuationAlignPadding(2, align_style, 4, 8)
self.assertEqual(pad, "\t" * 2)
self.assertEqual(pad, '\t' * 2)
pad = format_token._TabbedContinuationAlignPadding(5, align_style, 4, 8)
self.assertEqual(pad, "\t" * 2)
self.assertEqual(pad, '\t' * 2)
def testVAlignRight(self):
align_style = 'VALIGN-RIGHT'
@ -54,13 +54,13 @@ class TabbedContinuationAlignPaddingTest(unittest.TestCase):
self.assertEqual(pad, '')
pad = format_token._TabbedContinuationAlignPadding(2, align_style, 4, 8)
self.assertEqual(pad, "\t")
self.assertEqual(pad, '\t')
pad = format_token._TabbedContinuationAlignPadding(4, align_style, 4, 8)
self.assertEqual(pad, "\t")
self.assertEqual(pad, '\t')
pad = format_token._TabbedContinuationAlignPadding(5, align_style, 4, 8)
self.assertEqual(pad, "\t" * 2)
self.assertEqual(pad, '\t' * 2)
class FormatTokenTest(unittest.TestCase):
@ -70,8 +70,8 @@ class FormatTokenTest(unittest.TestCase):
self.assertEqual("FormatToken(name=STRING, value='hello world')", str(tok))
self.assertTrue(tok.is_string)
tok = format_token.FormatToken(pytree.Leaf(token.COMMENT, "# A comment"))
self.assertEqual("FormatToken(name=COMMENT, value=# A comment)", str(tok))
tok = format_token.FormatToken(pytree.Leaf(token.COMMENT, '# A comment'))
self.assertEqual('FormatToken(name=COMMENT, value=# A comment)', str(tok))
self.assertTrue(tok.is_comment)
def testIsMultilineString(self):
@ -82,5 +82,5 @@ class FormatTokenTest(unittest.TestCase):
self.assertTrue(tok.is_multiline_string)
if __name__ == "__main__":
if __name__ == '__main__':
unittest.main()

@ -37,8 +37,8 @@ class UtilsTest(unittest.TestCase):
'VALIGN-RIGHT')
with self.assertRaises(ValueError) as ctx:
style._ContinuationAlignStyleStringConverter('blahblah')
self.assertTrue(
"unknown continuation align style: 'blahblah'" in str(ctx.exception))
self.assertIn("unknown continuation align style: 'blahblah'",
str(ctx.exception))
def testStringListConverter(self):
self.assertEqual(style._StringListConverter('foo, bar'), ['foo', 'bar'])

Loading…
Cancel
Save