Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-indent the contents of docstrings #1053

Merged
merged 4 commits into from
May 8, 2020
Merged

Commits on Nov 12, 2019

  1. Re-indent the contents of docstrings when indentation changes

    Keeping the contents of docstrings completely unchanged when
    re-indenting (from 2-space intents to 4, for example) can cause
    incorrect docstring indentation:
    
    ```
    class MyClass:
      """Multiline
      class docstring
      """
    
      def method(self):
        """Multiline
        method docstring
        """
        pass
    ```
    ...becomes:
    ```
    class MyClass:
        """Multiline
      class docstring
      """
    
        def method(self):
            """Multiline
        method docstring
        """
            pass
    ```
    
    This uses the PEP 257 algorithm for determining docstring indentation,
    and adjusts the contents of docstrings to match their new indentation
    after `black` is applied.
    
    A small normalization is necessary to `assert_equivalent` because the
    trees are technically no longer precisely equivalent -- some constant
    strings have changed.  When comparing two ASTs, whitespace after
    newlines within constant strings is thus folded into a single space.
    
    Co-authored-by: Luka Zakrajšek <[email protected]>
    Alex Vandiver and bancek committed Nov 12, 2019
    Configuration menu
    Copy the full SHA
    7c111fd View commit details
    Browse the repository at this point in the history
  2. Extract the inner _v method to decrease complexity

    This reduces the cyclomatic complexity to a level that makes flake8 happy.
    Alex Vandiver committed Nov 12, 2019
    Configuration menu
    Copy the full SHA
    a28e5a5 View commit details
    Browse the repository at this point in the history
  3. Blacken blib2to3's docstring which had an over-indent

    Alex Vandiver committed Nov 12, 2019
    Configuration menu
    Copy the full SHA
    93d6b8f View commit details
    Browse the repository at this point in the history

Commits on May 8, 2020

  1. Configuration menu
    Copy the full SHA
    b9352d3 View commit details
    Browse the repository at this point in the history