Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package python-yapf for openSUSE:Factory 
checked in at 2021-07-21 19:05:31
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-yapf (Old)
 and      /work/SRC/openSUSE:Factory/.python-yapf.new.2632 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-yapf"

Wed Jul 21 19:05:31 2021 rev:10 rq:906775 version:0.31.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-yapf/python-yapf.changes  2020-06-02 
14:36:10.423053469 +0200
+++ /work/SRC/openSUSE:Factory/.python-yapf.new.2632/python-yapf.changes        
2021-07-21 19:05:35.367209063 +0200
@@ -1,0 +2,12 @@
+Sat Jul 17 06:43:41 UTC 2021 - Dirk M??ller <[email protected]>
+
+- update to 0.31.0:
+  - Add 'BLANK_LINES_BETWEEN_TOP_LEVEL_IMPORTS_AND_VARIABLES' to support 
setting
+  a custom number of blank lines between top-level imports and variable
+  definitions.
+  - Ignore end of line `# copybara:` directives when checking line length.
+  - Do not scan exlcuded directories. Prior versions would scan an exluded
+  folder then exclude its contents on a file by file basis. Preventing the
+  folder being scanned is faster.
+
+-------------------------------------------------------------------

Old:
----
  yapf-0.30.0.tar.gz

New:
----
  yapf-0.31.0.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-yapf.spec ++++++
--- /var/tmp/diff_new_pack.ndPyPv/_old  2021-07-21 19:05:35.895209980 +0200
+++ /var/tmp/diff_new_pack.ndPyPv/_new  2021-07-21 19:05:35.899209987 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package python-yapf
 #
-# Copyright (c) 2020 SUSE LLC
+# Copyright (c) 2021 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -18,7 +18,7 @@
 
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 Name:           python-yapf
-Version:        0.30.0
+Version:        0.31.0
 Release:        0
 Summary:        A formatter for Python code
 License:        Apache-2.0
@@ -30,7 +30,7 @@
 BuildRequires:  fdupes
 BuildRequires:  python-rpm-macros
 Requires(post): update-alternatives
-Requires(postun): update-alternatives
+Requires(postun):update-alternatives
 BuildArch:      noarch
 %ifpython2
 Recommends:     python-futures
@@ -58,6 +58,7 @@
 %python_expand %fdupes %{buildroot}%{$python_sitelib}
 
 %python_clone -a %{buildroot}%{_bindir}/yapf
+%python_clone -a %{buildroot}%{_bindir}/yapf-diff
 %python_expand rm -r %{buildroot}%{$python_sitelib}/yapftests
 
 %check
@@ -73,6 +74,7 @@
 %license LICENSE
 %doc README.rst CHANGELOG
 %python_alternative %{_bindir}/yapf
+%python_alternative %{_bindir}/yapf-diff
 %{python_sitelib}/yapf/
 %{python_sitelib}/yapf-%{version}-py*.egg-info/
 

++++++ yapf-0.30.0.tar.gz -> yapf-0.31.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yapf-0.30.0/CHANGELOG new/yapf-0.31.0/CHANGELOG
--- old/yapf-0.30.0/CHANGELOG   2020-04-23 21:05:35.000000000 +0200
+++ new/yapf-0.31.0/CHANGELOG   2021-03-12 22:41:30.000000000 +0100
@@ -2,6 +2,22 @@
 # All notable changes to this project will be documented in this file.
 # This project adheres to [Semantic Versioning](http://semver.org/).
 
+## [0.31.0] 2021-03-14
+### Added
+- Renamed 'master' brannch to 'main'.
+- Add 'BLANK_LINES_BETWEEN_TOP_LEVEL_IMPORTS_AND_VARIABLES' to support setting
+  a custom number of blank lines between top-level imports and variable
+  definitions.
+- Ignore end of line `# copybara:` directives when checking line length.
+- Look at the 'pyproject.toml' file to see if it contains style information for
+  YAPF.
+### Changed
+- Do not scan exlcuded directories. Prior versions would scan an exluded
+  folder then exclude its contents on a file by file basis. Preventing the
+  folder being scanned is faster.
+### Fixed
+- Exclude directories on Windows.
+
 ## [0.30.0] 2020-04-23
 ### Added
 - Added `SPACES_AROUND_LIST_DELIMITERS`, `SPACES_AROUND_DICT_DELIMITERS`,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yapf-0.30.0/CONTRIBUTORS new/yapf-0.31.0/CONTRIBUTORS
--- old/yapf-0.30.0/CONTRIBUTORS        2019-07-10 09:33:15.000000000 +0200
+++ new/yapf-0.31.0/CONTRIBUTORS        2021-01-23 06:59:32.000000000 +0100
@@ -14,3 +14,4 @@
 Sam Clegg <[email protected]>
 ??ukasz Langa <[email protected]>
 Oleg Butuzov <[email protected]>
+Mauricio Herrera Cuadra <[email protected]>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yapf-0.30.0/PKG-INFO new/yapf-0.31.0/PKG-INFO
--- old/yapf-0.30.0/PKG-INFO    2020-04-23 21:06:42.000000000 +0200
+++ new/yapf-0.31.0/PKG-INFO    2021-03-12 22:43:33.000000000 +0100
@@ -1,6 +1,6 @@
 Metadata-Version: 1.2
 Name: yapf
-Version: 0.30.0
+Version: 0.31.0
 Summary: A formatter for Python code.
 Home-page: UNKNOWN
 Author: Google Inc.
@@ -15,12 +15,12 @@
             :target: https://badge.fury.io/py/yapf
             :alt: PyPI version
         
-        .. image:: https://travis-ci.org/google/yapf.svg?branch=master
+        .. image:: https://travis-ci.org/google/yapf.svg?branch=main
             :target: https://travis-ci.org/google/yapf
             :alt: Build status
         
-        .. image:: 
https://coveralls.io/repos/google/yapf/badge.svg?branch=master
-            :target: https://coveralls.io/r/google/yapf?branch=master
+        .. image:: https://coveralls.io/repos/google/yapf/badge.svg?branch=main
+            :target: https://coveralls.io/r/google/yapf?branch=main
             :alt: Coverage status
         
         
@@ -46,8 +46,6 @@
         programmer would write if they were following the style guide. It 
takes away
         some of the drudgery of maintaining your code.
         
-        Try out YAPF with this `online demo <https://yapf.now.sh>`_.
-        
         .. footer::
         
             YAPF is not an official Google product (experimental or 
otherwise), it is
@@ -124,10 +122,10 @@
               --style STYLE         specify formatting style: either a style 
name (for
                                     example "pep8" or "google"), or the name 
of a file
                                     with style settings. The default is pep8 
unless a
-                                    .style.yapf or setup.cfg file located in 
the same
-                                    directory as the source or one of its 
parent
-                                    directories (for stdin, the current 
directory is
-                                    used).
+                                    .style.yapf or setup.cfg or pyproject.toml 
file
+                                    located in the same directory as the 
source or one of
+                                    its parent directories (for stdin, the 
current
+                                    directory is used).
               --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
@@ -187,10 +185,18 @@
         
         The ``based_on_style`` setting determines which of the predefined 
styles this
         custom style is based on (think of it like subclassing). Four
-        styles are predefined: ``pep8`` (default), ``google``, ``yapf``, and 
``facebook``
-        (see ``_STYLE_NAME_TO_FACTORY`` in style.py_).
+        styles are predefined:
+        
+        - ``pep8`` (default)
+        - ``google`` (based off of the `Google Python Style Guide`_)
+        - ``yapf`` (for use with Google open source projects)
+        - ``facebook``
+        
+        .. _`Google Python Style Guide`: 
https://github.com/google/styleguide/blob/gh-pages/pyguide.md
         
-        .. _style.py: 
https://github.com/google/yapf/blob/master/yapf/yapflib/style.py#L445
+        See ``_STYLE_NAME_TO_FACTORY`` in style.py_ for details.
+        
+        .. _style.py: 
https://github.com/google/yapf/blob/main/yapf/yapflib/style.py
         
         It's also possible to do the same on the command line with a 
dictionary. For
         example:
@@ -209,7 +215,9 @@
            directory or one of its parent directories.
         3. In the ``[yapf]`` section of a ``setup.cfg`` file in either the 
current
            directory or one of its parent directories.
-        4. In the ``[style]`` section of a ``~/.config/yapf/style`` file in 
your home
+        4. In the ``[tool.yapf]`` section of a ``pyproject.toml`` file in 
either the current
+           directory or one of its parent directories.
+        5. In the ``[style]`` section of a ``~/.config/yapf/style`` file in 
your home
            directory.
         
         If none of those files are found, the default style is used (PEP8).
@@ -330,6 +338,43 @@
             >>> print(open("foo.py").read())  # contents of file (now fixed)
             a == b
         
+        Formatting diffs
+        ================
+        
+        Options::
+        
+            usage: yapf-diff [-h] [-i] [-p NUM] [--regex PATTERN] [--iregex 
PATTERN][-v]
+                             [--style STYLE] [--binary BINARY]
+        
+            This script reads input from a unified diff and reformats all the 
changed
+            lines. This is useful to reformat all the lines touched by a 
specific patch.
+            Example usage for git/svn users:
+        
+              git diff -U0 --no-color --relative HEAD^ | yapf-diff -i
+              svn diff --diff-cmd=diff -x-U0 | yapf-diff -p0 -i
+        
+            It should be noted that the filename contained in the diff is used
+            unmodified to determine the source file to update. Users calling 
this script
+            directly should be careful to ensure that the path in the diff is 
correct
+            relative to the current working directory.
+        
+            optional arguments:
+              -h, --help            show this help message and exit
+              -i, --in-place        apply edits to files instead of displaying 
a diff
+              -p NUM, --prefix NUM  strip the smallest prefix containing P 
slashes
+              --regex PATTERN       custom pattern selecting file paths to 
reformat
+                                    (case sensitive, overrides -iregex)
+              --iregex PATTERN      custom pattern selecting file paths to 
reformat
+                                    (case insensitive, overridden by -regex)
+              -v, --verbose         be more verbose, ineffective without -i
+              --style STYLE         specify formatting style: either a style 
name (for
+                                    example "pep8" or "google"), or the name 
of a file
+                                    with style settings. The default is pep8 
unless a
+                                    .style.yapf or setup.cfg or pyproject.toml 
file
+                                    located in the same directory as the 
source or one of
+                                    its parent directories (for stdin, the 
current
+                                    directory is used).
+              --binary BINARY       location of binary to use for yapf
         
         Knobs
         =====
@@ -410,6 +455,10 @@
                 class Bar:
                     pass
         
+        ``BLANK_LINES_BETWEEN_TOP_LEVEL_IMPORTS_AND_VARIABLES``
+            Sets the number of desired blank lines between top-level imports 
and
+            variable definitions. Useful for compatibility with tools like 
isort.
+        
         ``COALESCE_BRACKETS``
             Do not split consecutive brackets. Only relevant when
             ``DEDENT_CLOSING_BRACKETS`` or ``INDENT_CLOSING_BRACKETS``
@@ -576,7 +625,7 @@
                 [1, 2]
         
             will be formatted as:
-            
+        
             .. code-block:: python
         
                 [ 1, 2 ]
@@ -674,16 +723,16 @@
             ``b`` in this code:
         
             .. code-block:: python
-              
+        
               abcdef(
                   aReallyLongThing: int,
                   b: [Int,
                       Int])
-           
+        
             With the new knob this is split as:
         
             .. code-block:: python
-              
+        
               abcdef(
                   aReallyLongThing: int,
                   b: [Int, Int])
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yapf-0.30.0/README.rst new/yapf-0.31.0/README.rst
--- old/yapf-0.30.0/README.rst  2020-04-23 20:28:54.000000000 +0200
+++ new/yapf-0.31.0/README.rst  2021-03-12 22:34:16.000000000 +0100
@@ -6,12 +6,12 @@
     :target: https://badge.fury.io/py/yapf
     :alt: PyPI version
 
-.. image:: https://travis-ci.org/google/yapf.svg?branch=master
+.. image:: https://travis-ci.org/google/yapf.svg?branch=main
     :target: https://travis-ci.org/google/yapf
     :alt: Build status
 
-.. image:: https://coveralls.io/repos/google/yapf/badge.svg?branch=master
-    :target: https://coveralls.io/r/google/yapf?branch=master
+.. image:: https://coveralls.io/repos/google/yapf/badge.svg?branch=main
+    :target: https://coveralls.io/r/google/yapf?branch=main
     :alt: Coverage status
 
 
@@ -37,8 +37,6 @@
 programmer would write if they were following the style guide. It takes away
 some of the drudgery of maintaining your code.
 
-Try out YAPF with this `online demo <https://yapf.now.sh>`_.
-
 .. footer::
 
     YAPF is not an official Google product (experimental or otherwise), it is
@@ -115,10 +113,10 @@
       --style STYLE         specify formatting style: either a style name (for
                             example "pep8" or "google"), or the name of a file
                             with style settings. The default is pep8 unless a
-                            .style.yapf or setup.cfg file located in the same
-                            directory as the source or one of its parent
-                            directories (for stdin, the current directory is
-                            used).
+                            .style.yapf or setup.cfg or pyproject.toml file
+                            located in the same directory as the source or one 
of
+                            its parent directories (for stdin, the current
+                            directory is used).
       --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
@@ -178,10 +176,18 @@
 
 The ``based_on_style`` setting determines which of the predefined styles this
 custom style is based on (think of it like subclassing). Four
-styles are predefined: ``pep8`` (default), ``google``, ``yapf``, and 
``facebook``
-(see ``_STYLE_NAME_TO_FACTORY`` in style.py_).
+styles are predefined:
+
+- ``pep8`` (default)
+- ``google`` (based off of the `Google Python Style Guide`_)
+- ``yapf`` (for use with Google open source projects)
+- ``facebook``
+
+.. _`Google Python Style Guide`: 
https://github.com/google/styleguide/blob/gh-pages/pyguide.md
 
-.. _style.py: 
https://github.com/google/yapf/blob/master/yapf/yapflib/style.py#L445
+See ``_STYLE_NAME_TO_FACTORY`` in style.py_ for details.
+
+.. _style.py: https://github.com/google/yapf/blob/main/yapf/yapflib/style.py
 
 It's also possible to do the same on the command line with a dictionary. For
 example:
@@ -200,7 +206,9 @@
    directory or one of its parent directories.
 3. In the ``[yapf]`` section of a ``setup.cfg`` file in either the current
    directory or one of its parent directories.
-4. In the ``[style]`` section of a ``~/.config/yapf/style`` file in your home
+4. In the ``[tool.yapf]`` section of a ``pyproject.toml`` file in either the 
current
+   directory or one of its parent directories.
+5. In the ``[style]`` section of a ``~/.config/yapf/style`` file in your home
    directory.
 
 If none of those files are found, the default style is used (PEP8).
@@ -321,6 +329,43 @@
     >>> print(open("foo.py").read())  # contents of file (now fixed)
     a == b
 
+Formatting diffs
+================
+
+Options::
+
+    usage: yapf-diff [-h] [-i] [-p NUM] [--regex PATTERN] [--iregex 
PATTERN][-v]
+                     [--style STYLE] [--binary BINARY]
+
+    This script reads input from a unified diff and reformats all the changed
+    lines. This is useful to reformat all the lines touched by a specific 
patch.
+    Example usage for git/svn users:
+
+      git diff -U0 --no-color --relative HEAD^ | yapf-diff -i
+      svn diff --diff-cmd=diff -x-U0 | yapf-diff -p0 -i
+
+    It should be noted that the filename contained in the diff is used
+    unmodified to determine the source file to update. Users calling this 
script
+    directly should be careful to ensure that the path in the diff is correct
+    relative to the current working directory.
+
+    optional arguments:
+      -h, --help            show this help message and exit
+      -i, --in-place        apply edits to files instead of displaying a diff
+      -p NUM, --prefix NUM  strip the smallest prefix containing P slashes
+      --regex PATTERN       custom pattern selecting file paths to reformat
+                            (case sensitive, overrides -iregex)
+      --iregex PATTERN      custom pattern selecting file paths to reformat
+                            (case insensitive, overridden by -regex)
+      -v, --verbose         be more verbose, ineffective without -i
+      --style STYLE         specify formatting style: either a style name (for
+                            example "pep8" or "google"), or the name of a file
+                            with style settings. The default is pep8 unless a
+                            .style.yapf or setup.cfg or pyproject.toml file
+                            located in the same directory as the source or one 
of
+                            its parent directories (for stdin, the current
+                            directory is used).
+      --binary BINARY       location of binary to use for yapf
 
 Knobs
 =====
@@ -401,6 +446,10 @@
         class Bar:
             pass
 
+``BLANK_LINES_BETWEEN_TOP_LEVEL_IMPORTS_AND_VARIABLES``
+    Sets the number of desired blank lines between top-level imports and
+    variable definitions. Useful for compatibility with tools like isort.
+
 ``COALESCE_BRACKETS``
     Do not split consecutive brackets. Only relevant when
     ``DEDENT_CLOSING_BRACKETS`` or ``INDENT_CLOSING_BRACKETS``
@@ -567,7 +616,7 @@
         [1, 2]
 
     will be formatted as:
-    
+
     .. code-block:: python
 
         [ 1, 2 ]
@@ -665,16 +714,16 @@
     ``b`` in this code:
 
     .. code-block:: python
-      
+
       abcdef(
           aReallyLongThing: int,
           b: [Int,
               Int])
-   
+
     With the new knob this is split as:
 
     .. code-block:: python
-      
+
       abcdef(
           aReallyLongThing: int,
           b: [Int, Int])
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yapf-0.30.0/plugins/README.rst 
new/yapf-0.31.0/plugins/README.rst
--- old/yapf-0.30.0/plugins/README.rst  2018-01-14 06:59:08.000000000 +0100
+++ new/yapf-0.31.0/plugins/README.rst  2021-01-23 07:12:05.000000000 +0100
@@ -65,7 +65,7 @@
 .. code-block:: bash
 
     # From the root of your git project.
-    curl -o pre-commit.sh 
https://raw.githubusercontent.com/google/yapf/master/plugins/pre-commit.sh
+    curl -o pre-commit.sh 
https://raw.githubusercontent.com/google/yapf/main/plugins/pre-commit.sh
     chmod a+x pre-commit.sh
     mv pre-commit.sh .git/hooks/pre-commit
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yapf-0.30.0/setup.py new/yapf-0.31.0/setup.py
--- old/yapf-0.30.0/setup.py    2018-01-27 00:07:45.000000000 +0100
+++ new/yapf-0.31.0/setup.py    2021-01-23 06:59:32.000000000 +0100
@@ -65,7 +65,10 @@
           'Topic :: Software Development :: Quality Assurance',
       ],
       entry_points={
-          'console_scripts': ['yapf = yapf:run_main'],
+          'console_scripts': [
+              'yapf = yapf:run_main',
+              'yapf-diff = yapf.third_party.yapf_diff.yapf_diff:main',
+          ],
       },
       cmdclass={
           'test': RunTests,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yapf-0.30.0/tox.ini new/yapf-0.31.0/tox.ini
--- old/yapf-0.30.0/tox.ini     2017-04-21 07:48:44.000000000 +0200
+++ new/yapf-0.31.0/tox.ini     2021-01-23 06:59:32.000000000 +0100
@@ -1,5 +1,5 @@
 [tox]
-envlist=py27,py34,py35,py36
+envlist=py27,py34,py35,py36,py37,py38
 
 [testenv]
 commands=
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yapf-0.30.0/yapf/__init__.py 
new/yapf-0.31.0/yapf/__init__.py
--- old/yapf-0.30.0/yapf/__init__.py    2020-04-23 21:05:06.000000000 +0200
+++ new/yapf-0.31.0/yapf/__init__.py    2021-03-12 22:41:34.000000000 +0100
@@ -40,7 +40,7 @@
 from yapf.yapflib import style
 from yapf.yapflib import yapf_api
 
-__version__ = '0.30.0'
+__version__ = '0.31.0'
 
 
 def main(argv):
@@ -57,7 +57,8 @@
   Raises:
     YapfError: if none of the supplied files were Python files.
   """
-  args = _ParseArguments(argv)
+  parser = _BuildParser()
+  args = parser.parse_args(argv[1:])
   if args.version:
     print('yapf {}'.format(__version__))
     return 0
@@ -65,7 +66,7 @@
   style_config = args.style
 
   if args.style_help:
-    print_help(args)
+    _PrintHelp(args)
     return 0
 
   if args.lines and len(args.files) > 1:
@@ -136,7 +137,7 @@
   return 1 if changed and (args.diff or args.quiet) else 0
 
 
-def print_help(args):
+def _PrintHelp(args):
   """Prints the help menu."""
 
   if args.style is None and not args.no_local_style:
@@ -268,15 +269,11 @@
   return lines
 
 
-def _ParseArguments(argv):
-  """Parse the command line arguments.
-
-  Arguments:
-    argv: command-line arguments, such as sys.argv (including the program name
-      in argv[0]).
+def _BuildParser():
+  """Constructs the parser for the command line arguments.
 
   Returns:
-    An object containing the arguments used to invoke the program.
+    An ArgumentParser instance for the CLI.
   """
   parser = argparse.ArgumentParser(description='Formatter for Python code.')
   parser.add_argument(
@@ -328,10 +325,10 @@
       action='store',
       help=('specify formatting style: either a style name (for example "pep8" 
'
             'or "google"), or the name of a file with style settings. The '
-            'default is pep8 unless a %s or %s file located in the same '
+            'default is pep8 unless a %s or %s or %s file located in the same '
             'directory as the source or one of its parent directories '
             '(for stdin, the current directory is used).' %
-            (style.LOCAL_STYLE, style.SETUP_CONFIG)))
+            (style.LOCAL_STYLE, style.SETUP_CONFIG, style.PYPROJECT_TOML)))
   parser.add_argument(
       '--style-help',
       action='store_true',
@@ -357,7 +354,7 @@
 
   parser.add_argument(
       'files', nargs='*', help='reads from stdin when no files are specified.')
-  return parser.parse_args(argv[1:])
+  return parser
 
 
 def run_main():  # pylint: disable=invalid-name
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yapf-0.30.0/yapf/yapflib/file_resources.py 
new/yapf-0.31.0/yapf/yapflib/file_resources.py
--- old/yapf-0.30.0/yapf/yapflib/file_resources.py      2020-04-23 
20:08:28.000000000 +0200
+++ new/yapf-0.31.0/yapf/yapflib/file_resources.py      2021-03-12 
22:34:16.000000000 +0100
@@ -67,7 +67,7 @@
 def GetDefaultStyleForDir(dirname, default_style=style.DEFAULT_STYLE):
   """Return default style name for a given directory.
 
-  Looks for .style.yapf or setup.cfg in the parent directories.
+  Looks for .style.yapf or setup.cfg or pyproject.toml in the parent 
directories.
 
   Arguments:
     dirname: (unicode) The name of the directory.
@@ -97,6 +97,26 @@
         if config.has_section('yapf'):
           return config_file
 
+    # See if we have a pyproject.toml file with a '[tool.yapf]'  section.
+    config_file = os.path.join(dirname, style.PYPROJECT_TOML)
+    try:
+      fd = open(config_file)
+    except IOError:
+      pass  # It's okay if it's not there.
+    else:
+      with fd:
+        try:
+          import toml
+        except ImportError:
+          raise errors.YapfError(
+              "toml package is needed for using pyproject.toml as a 
configuration file"
+          )
+
+        pyproject_toml = toml.load(config_file)
+        style_dict = pyproject_toml.get('tool', {}).get('yapf', None)
+        if style_dict is not None:
+          return config_file
+
     if (not dirname or not os.path.basename(dirname) or
         dirname == os.path.abspath(os.path.sep)):
       break
@@ -154,6 +174,7 @@
   """Find all Python files."""
   if exclude and any(e.startswith('./') for e in exclude):
     raise errors.YapfError("path in '--exclude' should not start with ./")
+  exclude = exclude and [e.rstrip("/" + os.path.sep) for e in exclude]
 
   python_files = []
   for filename in filenames:
@@ -166,7 +187,7 @@
 
       # TODO(morbo): Look into a version of os.walk that can handle recursion.
       excluded_dirs = []
-      for dirpath, _, filelist in os.walk(filename):
+      for dirpath, dirnames, filelist in os.walk(filename):
         if dirpath != '.' and exclude and IsIgnored(dirpath, exclude):
           excluded_dirs.append(dirpath)
           continue
@@ -178,6 +199,19 @@
             continue
           if IsPythonFile(filepath):
             python_files.append(filepath)
+        # To prevent it from scanning the contents excluded folders, os.walk()
+        # lets you amend its list of child dirs `dirnames`. These edits must be
+        # made in-place instead of creating a modified copy of `dirnames`.
+        # list.remove() is slow and list.pop() is a headache. Instead clear
+        # `dirnames` then repopulate it.
+        dirnames_ = [dirnames.pop(0) for i in range(len(dirnames))]
+        for dirname in dirnames_:
+          dir_ = os.path.join(dirpath, dirname)
+          if IsIgnored(dir_, exclude):
+            excluded_dirs.append(dir_)
+          else:
+            dirnames.append(dirname)
+
     elif os.path.isfile(filename):
       python_files.append(filename)
 
@@ -186,10 +220,12 @@
 
 def IsIgnored(path, exclude):
   """Return True if filename matches any patterns in exclude."""
-  path = path.lstrip('/')
-  while path.startswith('./'):
+  if exclude is None:
+    return False
+  path = path.lstrip(os.path.sep)
+  while path.startswith('.' + os.path.sep):
     path = path[2:]
-  return any(fnmatch.fnmatch(path, e.rstrip('/')) for e in exclude)
+  return any(fnmatch.fnmatch(path, e.rstrip(os.path.sep)) for e in exclude)
 
 
 def IsPythonFile(filename):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yapf-0.30.0/yapf/yapflib/format_decision_state.py 
new/yapf-0.31.0/yapf/yapflib/format_decision_state.py
--- old/yapf-0.30.0/yapf/yapflib/format_decision_state.py       2020-04-23 
20:28:54.000000000 +0200
+++ new/yapf-0.31.0/yapf/yapflib/format_decision_state.py       2021-01-23 
07:10:19.000000000 +0100
@@ -742,7 +742,7 @@
     # Calculate the penalty for overflowing the column limit.
     penalty = 0
     if (not current.is_pylint_comment and not current.is_pytype_comment and
-        self.column > self.column_limit):
+        not current.is_copybara_comment and self.column > self.column_limit):
       excess_characters = self.column - self.column_limit
       penalty += style.Get('SPLIT_PENALTY_EXCESS_CHARACTER') * 
excess_characters
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yapf-0.30.0/yapf/yapflib/format_token.py 
new/yapf-0.31.0/yapf/yapflib/format_token.py
--- old/yapf-0.30.0/yapf/yapflib/format_token.py        2020-04-23 
20:28:54.000000000 +0200
+++ new/yapf-0.31.0/yapf/yapflib/format_token.py        2021-01-23 
06:59:32.000000000 +0100
@@ -378,3 +378,8 @@
   def is_pytype_comment(self):
     return self.is_comment and re.match(r'#.*\bpytype:\s*(disable|enable)=',
                                         self.value)
+
+  @property
+  def is_copybara_comment(self):
+    return self.is_comment and 
re.match(r'#.*\bcopybara:(strip|insert|replace)',
+                                        self.value)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yapf-0.30.0/yapf/yapflib/py3compat.py 
new/yapf-0.31.0/yapf/yapflib/py3compat.py
--- old/yapf-0.30.0/yapf/yapflib/py3compat.py   2018-11-25 09:06:34.000000000 
+0100
+++ new/yapf-0.31.0/yapf/yapflib/py3compat.py   2021-01-23 06:59:32.000000000 
+0100
@@ -20,6 +20,8 @@
 
 PY3 = sys.version_info[0] >= 3
 PY36 = sys.version_info[0] >= 3 and sys.version_info[1] >= 6
+PY37 = sys.version_info[0] >= 3 and sys.version_info[1] >= 7
+PY38 = sys.version_info[0] >= 3 and sys.version_info[1] >= 8
 
 if PY3:
   StringIO = io.StringIO
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yapf-0.30.0/yapf/yapflib/reformatter.py 
new/yapf-0.31.0/yapf/yapflib/reformatter.py
--- old/yapf-0.30.0/yapf/yapflib/reformatter.py 2020-04-23 20:08:28.000000000 
+0200
+++ new/yapf-0.31.0/yapf/yapflib/reformatter.py 2021-01-23 07:10:19.000000000 
+0100
@@ -115,10 +115,6 @@
 
 def _RetainRequiredVerticalSpacing(cur_uwline, prev_uwline, lines):
   """Retain all vertical spacing between lines."""
-  if cur_uwline.disable and (not prev_uwline or prev_uwline.disable):
-    # If both lines are disabled we aren't allowed to reformat anything.
-    lines = set()
-
   prev_tok = None
   if prev_uwline is not None:
     prev_tok = prev_uwline.last
@@ -160,7 +156,7 @@
   if cur_tok.is_comment and not prev_tok.is_comment:
     # Don't adjust between a comment and non-comment.
     pass
-  elif lines and (cur_lineno in lines or prev_lineno in lines):
+  elif lines and lines.intersection(range(prev_lineno, cur_lineno + 1)):
     desired_newlines = cur_tok.whitespace_prefix.count('\n')
     whitespace_lines = range(prev_lineno + 1, cur_lineno)
     deletable_lines = len(lines.intersection(whitespace_lines))
@@ -263,7 +259,8 @@
   indent_amt = style.Get('INDENT_WIDTH') * uwline.depth
   last = uwline.last
   last_index = -1
-  if last.is_pylint_comment or last.is_pytype_comment:
+  if (last.is_pylint_comment or last.is_pytype_comment or
+      last.is_copybara_comment):
     last = last.previous_token
     last_index = -2
   if last is None:
@@ -650,6 +647,14 @@
     # The docstring shouldn't have a newline before it.
     return NO_BLANK_LINES
 
+  if first_token.is_name and not indent_depth:
+    if (prev_uwline.first.value == 'from' or
+        prev_uwline.first.value == 'import'):
+      # Support custom number of blank lines between top-level imports and
+      # variable definitions.
+      return 1 + style.Get(
+          'BLANK_LINES_BETWEEN_TOP_LEVEL_IMPORTS_AND_VARIABLES')
+
   prev_last_token = prev_uwline.last
   if prev_last_token.is_docstring:
     if (not indent_depth and first_token.value in {'class', 'def', 'async'}):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yapf-0.30.0/yapf/yapflib/style.py 
new/yapf-0.31.0/yapf/yapflib/style.py
--- old/yapf-0.30.0/yapf/yapflib/style.py       2020-04-23 20:28:54.000000000 
+0200
+++ new/yapf-0.31.0/yapf/yapflib/style.py       2021-03-12 22:34:16.000000000 
+0100
@@ -104,6 +104,9 @@
     BLANK_LINES_AROUND_TOP_LEVEL_DEFINITION=textwrap.dedent("""\
       Number of blank lines surrounding top-level function and class
       definitions."""),
+    BLANK_LINES_BETWEEN_TOP_LEVEL_IMPORTS_AND_VARIABLES=textwrap.dedent("""\
+      Number of blank lines between top-level imports and variable
+      definitions."""),
     COALESCE_BRACKETS=textwrap.dedent("""\
       Do not split consecutive brackets. Only relevant when
       dedent_closing_brackets is set. For example:
@@ -419,6 +422,7 @@
       BLANK_LINE_BEFORE_CLASS_DOCSTRING=False,
       BLANK_LINE_BEFORE_MODULE_DOCSTRING=False,
       BLANK_LINES_AROUND_TOP_LEVEL_DEFINITION=2,
+      BLANK_LINES_BETWEEN_TOP_LEVEL_IMPORTS_AND_VARIABLES=1,
       COALESCE_BRACKETS=False,
       COLUMN_LIMIT=79,
       CONTINUATION_ALIGN_STYLE='SPACE',
@@ -606,6 +610,7 @@
     BLANK_LINE_BEFORE_CLASS_DOCSTRING=_BoolConverter,
     BLANK_LINE_BEFORE_MODULE_DOCSTRING=_BoolConverter,
     BLANK_LINES_AROUND_TOP_LEVEL_DEFINITION=int,
+    BLANK_LINES_BETWEEN_TOP_LEVEL_IMPORTS_AND_VARIABLES=int,
     COALESCE_BRACKETS=_BoolConverter,
     COLUMN_LIMIT=int,
     CONTINUATION_ALIGN_STYLE=_ContinuationAlignStyleStringConverter,
@@ -737,19 +742,40 @@
         '"{0}" is not a valid style or file path'.format(config_filename))
   with open(config_filename) as style_file:
     config = py3compat.ConfigParser()
+    if config_filename.endswith(PYPROJECT_TOML):
+      try:
+        import toml
+      except ImportError:
+        raise errors.YapfError(
+            "toml package is needed for using pyproject.toml as a 
configuration file"
+        )
+
+      pyproject_toml = toml.load(style_file)
+      style_dict = pyproject_toml.get("tool", {}).get("yapf", None)
+      if style_dict is None:
+        raise StyleConfigError(
+            'Unable to find section [tool.yapf] in 
{0}'.format(config_filename))
+      config.add_section('style')
+      for k, v in style_dict.items():
+        config.set('style', k, str(v))
+      return config
+
     config.read_file(style_file)
     if config_filename.endswith(SETUP_CONFIG):
       if not config.has_section('yapf'):
         raise StyleConfigError(
             'Unable to find section [yapf] in {0}'.format(config_filename))
-    elif config_filename.endswith(LOCAL_STYLE):
-      if not config.has_section('style'):
-        raise StyleConfigError(
-            'Unable to find section [style] in {0}'.format(config_filename))
-    else:
+      return config
+
+    if config_filename.endswith(LOCAL_STYLE):
       if not config.has_section('style'):
         raise StyleConfigError(
             'Unable to find section [style] in {0}'.format(config_filename))
+      return config
+
+    if not config.has_section('style'):
+      raise StyleConfigError(
+          'Unable to find section [style] in {0}'.format(config_filename))
     return config
 
 
@@ -812,6 +838,10 @@
 # specified in the '[yapf]' section.
 SETUP_CONFIG = 'setup.cfg'
 
+# Style definition by local pyproject.toml file. Style should be specified
+# in the '[tool.yapf]' section.
+PYPROJECT_TOML = 'pyproject.toml'
+
 # TODO(eliben): For now we're preserving the global presence of a style dict.
 # Refactor this so that the style is passed around through yapf rather than
 # being global.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yapf-0.30.0/yapf/yapflib/unwrapped_line.py 
new/yapf-0.31.0/yapf/yapflib/unwrapped_line.py
--- old/yapf-0.30.0/yapf/yapflib/unwrapped_line.py      2020-04-23 
20:08:28.000000000 +0200
+++ new/yapf-0.31.0/yapf/yapflib/unwrapped_line.py      2021-01-23 
06:59:32.000000000 +0100
@@ -366,9 +366,9 @@
     if lval == '**' or rval == '**':
       # Space around the "power" operator.
       return style.Get('SPACES_AROUND_POWER_OPERATOR')
-    # Enforce spaces around binary operators except the blacklisted ones.
-    blacklist = style.Get('NO_SPACES_AROUND_SELECTED_BINARY_OPERATORS')
-    if lval in blacklist or rval in blacklist:
+    # Enforce spaces around binary operators except the blocked ones.
+    block_list = style.Get('NO_SPACES_AROUND_SELECTED_BINARY_OPERATORS')
+    if lval in block_list or rval in block_list:
       return False
     if style.Get('ARITHMETIC_PRECEDENCE_INDICATION'):
       if _PriorityIndicatingNoSpace(left) or _PriorityIndicatingNoSpace(right):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yapf-0.30.0/yapf.egg-info/PKG-INFO 
new/yapf-0.31.0/yapf.egg-info/PKG-INFO
--- old/yapf-0.30.0/yapf.egg-info/PKG-INFO      2020-04-23 21:06:42.000000000 
+0200
+++ new/yapf-0.31.0/yapf.egg-info/PKG-INFO      2021-03-12 22:43:33.000000000 
+0100
@@ -1,6 +1,6 @@
 Metadata-Version: 1.2
 Name: yapf
-Version: 0.30.0
+Version: 0.31.0
 Summary: A formatter for Python code.
 Home-page: UNKNOWN
 Author: Google Inc.
@@ -15,12 +15,12 @@
             :target: https://badge.fury.io/py/yapf
             :alt: PyPI version
         
-        .. image:: https://travis-ci.org/google/yapf.svg?branch=master
+        .. image:: https://travis-ci.org/google/yapf.svg?branch=main
             :target: https://travis-ci.org/google/yapf
             :alt: Build status
         
-        .. image:: 
https://coveralls.io/repos/google/yapf/badge.svg?branch=master
-            :target: https://coveralls.io/r/google/yapf?branch=master
+        .. image:: https://coveralls.io/repos/google/yapf/badge.svg?branch=main
+            :target: https://coveralls.io/r/google/yapf?branch=main
             :alt: Coverage status
         
         
@@ -46,8 +46,6 @@
         programmer would write if they were following the style guide. It 
takes away
         some of the drudgery of maintaining your code.
         
-        Try out YAPF with this `online demo <https://yapf.now.sh>`_.
-        
         .. footer::
         
             YAPF is not an official Google product (experimental or 
otherwise), it is
@@ -124,10 +122,10 @@
               --style STYLE         specify formatting style: either a style 
name (for
                                     example "pep8" or "google"), or the name 
of a file
                                     with style settings. The default is pep8 
unless a
-                                    .style.yapf or setup.cfg file located in 
the same
-                                    directory as the source or one of its 
parent
-                                    directories (for stdin, the current 
directory is
-                                    used).
+                                    .style.yapf or setup.cfg or pyproject.toml 
file
+                                    located in the same directory as the 
source or one of
+                                    its parent directories (for stdin, the 
current
+                                    directory is used).
               --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
@@ -187,10 +185,18 @@
         
         The ``based_on_style`` setting determines which of the predefined 
styles this
         custom style is based on (think of it like subclassing). Four
-        styles are predefined: ``pep8`` (default), ``google``, ``yapf``, and 
``facebook``
-        (see ``_STYLE_NAME_TO_FACTORY`` in style.py_).
+        styles are predefined:
+        
+        - ``pep8`` (default)
+        - ``google`` (based off of the `Google Python Style Guide`_)
+        - ``yapf`` (for use with Google open source projects)
+        - ``facebook``
+        
+        .. _`Google Python Style Guide`: 
https://github.com/google/styleguide/blob/gh-pages/pyguide.md
         
-        .. _style.py: 
https://github.com/google/yapf/blob/master/yapf/yapflib/style.py#L445
+        See ``_STYLE_NAME_TO_FACTORY`` in style.py_ for details.
+        
+        .. _style.py: 
https://github.com/google/yapf/blob/main/yapf/yapflib/style.py
         
         It's also possible to do the same on the command line with a 
dictionary. For
         example:
@@ -209,7 +215,9 @@
            directory or one of its parent directories.
         3. In the ``[yapf]`` section of a ``setup.cfg`` file in either the 
current
            directory or one of its parent directories.
-        4. In the ``[style]`` section of a ``~/.config/yapf/style`` file in 
your home
+        4. In the ``[tool.yapf]`` section of a ``pyproject.toml`` file in 
either the current
+           directory or one of its parent directories.
+        5. In the ``[style]`` section of a ``~/.config/yapf/style`` file in 
your home
            directory.
         
         If none of those files are found, the default style is used (PEP8).
@@ -330,6 +338,43 @@
             >>> print(open("foo.py").read())  # contents of file (now fixed)
             a == b
         
+        Formatting diffs
+        ================
+        
+        Options::
+        
+            usage: yapf-diff [-h] [-i] [-p NUM] [--regex PATTERN] [--iregex 
PATTERN][-v]
+                             [--style STYLE] [--binary BINARY]
+        
+            This script reads input from a unified diff and reformats all the 
changed
+            lines. This is useful to reformat all the lines touched by a 
specific patch.
+            Example usage for git/svn users:
+        
+              git diff -U0 --no-color --relative HEAD^ | yapf-diff -i
+              svn diff --diff-cmd=diff -x-U0 | yapf-diff -p0 -i
+        
+            It should be noted that the filename contained in the diff is used
+            unmodified to determine the source file to update. Users calling 
this script
+            directly should be careful to ensure that the path in the diff is 
correct
+            relative to the current working directory.
+        
+            optional arguments:
+              -h, --help            show this help message and exit
+              -i, --in-place        apply edits to files instead of displaying 
a diff
+              -p NUM, --prefix NUM  strip the smallest prefix containing P 
slashes
+              --regex PATTERN       custom pattern selecting file paths to 
reformat
+                                    (case sensitive, overrides -iregex)
+              --iregex PATTERN      custom pattern selecting file paths to 
reformat
+                                    (case insensitive, overridden by -regex)
+              -v, --verbose         be more verbose, ineffective without -i
+              --style STYLE         specify formatting style: either a style 
name (for
+                                    example "pep8" or "google"), or the name 
of a file
+                                    with style settings. The default is pep8 
unless a
+                                    .style.yapf or setup.cfg or pyproject.toml 
file
+                                    located in the same directory as the 
source or one of
+                                    its parent directories (for stdin, the 
current
+                                    directory is used).
+              --binary BINARY       location of binary to use for yapf
         
         Knobs
         =====
@@ -410,6 +455,10 @@
                 class Bar:
                     pass
         
+        ``BLANK_LINES_BETWEEN_TOP_LEVEL_IMPORTS_AND_VARIABLES``
+            Sets the number of desired blank lines between top-level imports 
and
+            variable definitions. Useful for compatibility with tools like 
isort.
+        
         ``COALESCE_BRACKETS``
             Do not split consecutive brackets. Only relevant when
             ``DEDENT_CLOSING_BRACKETS`` or ``INDENT_CLOSING_BRACKETS``
@@ -576,7 +625,7 @@
                 [1, 2]
         
             will be formatted as:
-            
+        
             .. code-block:: python
         
                 [ 1, 2 ]
@@ -674,16 +723,16 @@
             ``b`` in this code:
         
             .. code-block:: python
-              
+        
               abcdef(
                   aReallyLongThing: int,
                   b: [Int,
                       Int])
-           
+        
             With the new knob this is split as:
         
             .. code-block:: python
-              
+        
               abcdef(
                   aReallyLongThing: int,
                   b: [Int, Int])
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yapf-0.30.0/yapf.egg-info/entry_points.txt 
new/yapf-0.31.0/yapf.egg-info/entry_points.txt
--- old/yapf-0.30.0/yapf.egg-info/entry_points.txt      2020-04-23 
21:06:42.000000000 +0200
+++ new/yapf-0.31.0/yapf.egg-info/entry_points.txt      2021-03-12 
22:43:33.000000000 +0100
@@ -1,3 +1,4 @@
 [console_scripts]
 yapf = yapf:run_main
+yapf-diff = yapf.third_party.yapf_diff.yapf_diff:main
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yapf-0.30.0/yapftests/file_resources_test.py 
new/yapf-0.31.0/yapftests/file_resources_test.py
--- old/yapf-0.30.0/yapftests/file_resources_test.py    2020-04-23 
20:08:28.000000000 +0200
+++ new/yapf-0.31.0/yapftests/file_resources_test.py    2021-03-12 
22:39:28.000000000 +0100
@@ -117,6 +117,26 @@
     self.assertEqual(setup_config,
                      file_resources.GetDefaultStyleForDir(test_dir))
 
+  def test_pyproject_toml(self):
+    # An empty pyproject.toml file should not be used
+    try:
+      import toml
+    except ImportError:
+      return
+
+    pyproject_toml = os.path.join(self.test_tmpdir, 'pyproject.toml')
+    open(pyproject_toml, 'w').close()
+
+    test_dir = os.path.join(self.test_tmpdir, 'dir1')
+    style_name = file_resources.GetDefaultStyleForDir(test_dir)
+    self.assertEqual(style_name, 'pep8')
+
+    # One with a '[tool.yapf]' section should be used
+    with open(pyproject_toml, 'w') as f:
+      f.write('[tool.yapf]\n')
+    self.assertEqual(pyproject_toml,
+                     file_resources.GetDefaultStyleForDir(test_dir))
+
   def test_local_style_at_root(self):
     # Test behavior of files located on the root, and under root.
     rootdir = os.path.abspath(os.path.sep)
@@ -152,8 +172,8 @@
     self.old_dir = os.getcwd()
 
   def tearDown(self):  # pylint: disable=g-missing-super-call
-    shutil.rmtree(self.test_tmpdir)
     os.chdir(self.old_dir)
+    shutil.rmtree(self.test_tmpdir)
 
   def _make_test_dir(self, name):
     fullpath = os.path.normpath(os.path.join(self.test_tmpdir, name))
@@ -313,7 +333,8 @@
                                                'test2/testinner/',
                                            ]))
 
-    self.assertEqual(found, ['test3/foo/bar/bas/xxx/testfile3.py'])
+    self.assertEqual(
+        found, ['test3/foo/bar/bas/xxx/testfile3.py'.replace("/", 
os.path.sep)])
 
     found = sorted(
         file_resources.GetCommandLineFiles(['.'],
@@ -323,7 +344,8 @@
                                                'test3',
                                            ]))
 
-    self.assertEqual(found, ['./test2/testinner/testfile2.py'])
+    self.assertEqual(
+        found, ['./test2/testinner/testfile2.py'.replace("/", os.path.sep)])
 
   def test_find_with_excluded_current_dir(self):
     with self.assertRaises(errors.YapfError):
@@ -386,7 +408,7 @@
 
   def test_trailing_slash(self):
     self.assertTrue(file_resources.IsIgnored('z', ['z']))
-    self.assertTrue(file_resources.IsIgnored('z', ['z/']))
+    self.assertTrue(file_resources.IsIgnored('z', ['z' + os.path.sep]))
 
 
 class BufferedByteStream(object):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yapf-0.30.0/yapftests/reformatter_basic_test.py 
new/yapf-0.31.0/yapftests/reformatter_basic_test.py
--- old/yapf-0.30.0/yapftests/reformatter_basic_test.py 2020-04-23 
20:29:51.000000000 +0200
+++ new/yapf-0.31.0/yapftests/reformatter_basic_test.py 2021-01-23 
06:59:32.000000000 +0100
@@ -253,6 +253,95 @@
     uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
     self.assertCodeEqual(expected_formatted_code, 
reformatter.Reformat(uwlines))
 
+  def testBlankLinesBetweenTopLevelImportsAndVariables(self):
+    unformatted_code = textwrap.dedent("""\
+        import foo as bar
+        VAR = 'baz'
+        """)
+    expected_formatted_code = textwrap.dedent("""\
+        import foo as bar
+
+        VAR = 'baz'
+        """)
+    uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+    self.assertCodeEqual(expected_formatted_code, 
reformatter.Reformat(uwlines))
+
+    unformatted_code = textwrap.dedent("""\
+        import foo as bar
+
+        VAR = 'baz'
+        """)
+    expected_formatted_code = textwrap.dedent("""\
+        import foo as bar
+
+
+        VAR = 'baz'
+        """)
+    try:
+      style.SetGlobalStyle(
+          style.CreateStyleFromConfig(
+              '{based_on_style: yapf, 
blank_lines_between_top_level_imports_and_variables: 2}'
+          ))
+      uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+      self.assertCodeEqual(expected_formatted_code,
+                           reformatter.Reformat(uwlines))
+    finally:
+      style.SetGlobalStyle(style.CreateYapfStyle())
+
+    unformatted_code = textwrap.dedent("""\
+        import foo as bar
+        # Some comment
+        """)
+    expected_formatted_code = textwrap.dedent("""\
+        import foo as bar
+        # Some comment
+        """)
+    uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+    self.assertCodeEqual(expected_formatted_code, 
reformatter.Reformat(uwlines))
+
+    unformatted_code = textwrap.dedent("""\
+        import foo as bar
+        class Baz():
+          pass
+        """)
+    expected_formatted_code = textwrap.dedent("""\
+        import foo as bar
+
+
+        class Baz():
+          pass
+        """)
+    uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+    self.assertCodeEqual(expected_formatted_code, 
reformatter.Reformat(uwlines))
+
+    unformatted_code = textwrap.dedent("""\
+        import foo as bar
+        def foobar():
+          pass
+        """)
+    expected_formatted_code = textwrap.dedent("""\
+        import foo as bar
+
+
+        def foobar():
+          pass
+        """)
+    uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+    self.assertCodeEqual(expected_formatted_code, 
reformatter.Reformat(uwlines))
+
+    unformatted_code = textwrap.dedent("""\
+        def foobar():
+          from foo import Bar
+          Bar.baz()
+        """)
+    expected_formatted_code = textwrap.dedent("""\
+        def foobar():
+          from foo import Bar
+          Bar.baz()
+        """)
+    uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+    self.assertCodeEqual(expected_formatted_code, 
reformatter.Reformat(uwlines))
+
   def testBlankLinesAtEndOfFile(self):
     unformatted_code = textwrap.dedent("""\
         def foobar(): # foo
@@ -3033,6 +3122,19 @@
     finally:
       style.SetGlobalStyle(style.CreateYapfStyle())
 
+  @unittest.skipUnless(py3compat.PY38, 'Requires Python 3.8')
+  def testWalrus(self):
+    unformatted_code = textwrap.dedent("""\
+      if (x  :=  len([1]*1000)>100):
+        print(f'{x} is pretty big' )
+    """)
+    expected = textwrap.dedent("""\
+      if (x := len([1] * 1000) > 100):
+        print(f'{x} is pretty big')
+    """)
+    uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+    self.assertCodeEqual(expected, reformatter.Reformat(uwlines))
+
 
 if __name__ == '__main__':
   unittest.main()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yapf-0.30.0/yapftests/reformatter_buganizer_test.py 
new/yapf-0.31.0/yapftests/reformatter_buganizer_test.py
--- old/yapf-0.30.0/yapftests/reformatter_buganizer_test.py     2020-04-23 
20:28:54.000000000 +0200
+++ new/yapf-0.31.0/yapftests/reformatter_buganizer_test.py     2021-01-23 
06:59:32.000000000 +0100
@@ -166,7 +166,10 @@
   def _():
     X = (
         _ares_label_prefix +
-        
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')  
# pylint: disable=line-too-long
+        
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'  # 
pylint: disable=line-too-long
+        
'PyTypePyTypePyTypePyTypePyTypePyTypePyTypePyTypePyTypePyTypePyTypePyTypePyType'
  # pytype: disable=attribute-error
+        
'CopybaraCopybaraCopybaraCopybaraCopybaraCopybaraCopybaraCopybaraCopybara'  # 
copybara:strip
+    )
 """
     uwlines = yapf_test_helper.ParseAndUnwrap(code)
     self.assertCodeEqual(code, reformatter.Reformat(uwlines))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yapf-0.30.0/yapftests/style_test.py 
new/yapf-0.31.0/yapftests/style_test.py
--- old/yapf-0.30.0/yapftests/style_test.py     2020-04-23 20:28:54.000000000 
+0200
+++ new/yapf-0.31.0/yapftests/style_test.py     2021-03-12 22:39:40.000000000 
+0100
@@ -14,6 +14,7 @@
 # limitations under the License.
 """Tests for yapf.style."""
 
+import os
 import shutil
 import tempfile
 import textwrap
@@ -226,6 +227,36 @@
                                    'Unknown style option'):
         style.CreateStyleFromConfig(filepath)
 
+  def testPyprojectTomlNoYapfSection(self):
+    try:
+      import toml
+    except ImportError:
+      return
+
+    filepath = os.path.join(self.test_tmpdir, 'pyproject.toml')
+    _ = open(filepath, 'w')
+    with self.assertRaisesRegexp(style.StyleConfigError,
+                                 'Unable to find section'):
+      style.CreateStyleFromConfig(filepath)
+
+  def testPyprojectTomlParseYapfSection(self):
+    try:
+      import toml
+    except ImportError:
+      return
+
+    cfg = textwrap.dedent(u'''\
+        [tool.yapf]
+        based_on_style = "pep8"
+        continuation_indent_width = 40
+        ''')
+    filepath = os.path.join(self.test_tmpdir, 'pyproject.toml')
+    with open(filepath, 'w') as f:
+      f.write(cfg)
+    cfg = style.CreateStyleFromConfig(filepath)
+    self.assertTrue(_LooksLikePEP8Style(cfg))
+    self.assertEqual(cfg['CONTINUATION_INDENT_WIDTH'], 40)
+
 
 class StyleFromDict(unittest.TestCase):
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yapf-0.30.0/yapftests/yapf_test.py 
new/yapf-0.31.0/yapftests/yapf_test.py
--- old/yapf-0.30.0/yapftests/yapf_test.py      2020-04-23 20:31:31.000000000 
+0200
+++ new/yapf-0.31.0/yapftests/yapf_test.py      2021-01-23 06:59:32.000000000 
+0100
@@ -1016,6 +1016,29 @@
         expected_formatted_code,
         extra_options=['--lines', '4-7'])
 
+  def testRetainVerticalFormattingBetweenDisabledLines(self):
+    unformatted_code = textwrap.dedent("""\
+        class A(object):
+            def aaaaaaaaaaaaa(self):
+                pass
+
+
+            def bbbbbbbbbbbbb(self):  # 5
+                pass
+        """)
+    expected_formatted_code = textwrap.dedent("""\
+        class A(object):
+            def aaaaaaaaaaaaa(self):
+                pass
+
+            def bbbbbbbbbbbbb(self):  # 5
+                pass
+        """)
+    self.assertYapfReformats(
+        unformatted_code,
+        expected_formatted_code,
+        extra_options=['--lines', '4-4'])
+
   def testFormatLinesSpecifiedInMiddleOfExpression(self):
     unformatted_code = textwrap.dedent("""\
         class A(object):

Reply via email to