Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

fix(checker): allow whitespace before inner functions and class #426

Merged
merged 3 commits into from
Nov 30, 2019
Merged

fix(checker): allow whitespace before inner functions and class #426

merged 3 commits into from
Nov 30, 2019

Conversation

johanfleury
Copy link
Contributor

Changes D202: ("No blank lines allowed after function docstring") to
allow space below function docstrings with inner functions.

i.e. allows:

def outer():
    """Valid docstring."""

    def inner():
        pass

    return pass

See comment from @cdeil in #361.


This is a follow-up of PR #395.


  • Add unit tests and integration tests where applicable.
    If you've added an error code or changed an error code behavior,
    you should probably add or change a test case file under tests/test_cases/ and add
    it to the list under tests/test_definitions.py.
    If you've added or changed a command line option,
    you should probably add or change a test in tests/test_integration.py.
  • Add a line to the release notes (docs/release_notes.rst) under "Current Development Version".
    Make sure to include the PR number after you open and get one.

Changes D202: ("No blank lines allowed after function docstring") to
allow space below function docstrings with inner functions.

i.e. allows:

```python
def outer():
    """Valid docstring."""

    def inner():
        pass

    return pass
```

See comment from @cdeil in #361.
Copy link

@Code0x58 Code0x58 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just thought, there is the case of decorators around classes/functions, so that regex and test file could use @ cases.

For example it's fairly common to write a decorator that uses functions.wraps(...)

Avoid DeprecationWarning ("invalid escape sequence").
@johanfleury
Copy link
Contributor Author

I updated the PR and also added a commit to fix some DeprecationWarning.

Code0x58
Code0x58 previously approved these changes Oct 25, 2019
Copy link

@Code0x58 Code0x58 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

@ColinKennedy
Copy link

I just stumbled upon this PR. Is there anything that I can do to help it along or is it ready to merge?

@johanfleury
Copy link
Contributor Author

@ColinKennedy we're just waiting for a review by a project member.

@Nurdok
Copy link
Member

Nurdok commented Nov 21, 2019

Sorry for the long delays in response - I've been on back-to-back family vacation and business trips. I'll to catch up as soon as I can.

src/pydocstyle/checker.py Show resolved Hide resolved
@Nurdok Nurdok merged commit a1a4d0b into PyCQA:master Nov 30, 2019
daviddavis pushed a commit to daviddavis/pulp_ansible that referenced this pull request Dec 13, 2019
daviddavis pushed a commit to daviddavis/plugin_template that referenced this pull request Dec 13, 2019
daviddavis pushed a commit to daviddavis/pulp_ansible that referenced this pull request Dec 13, 2019
daviddavis pushed a commit to daviddavis/pulp_ansible that referenced this pull request Dec 13, 2019
rytilahti added a commit to rytilahti/python-kasa that referenced this pull request Apr 25, 2020
This is required as PyCQA/pydocstyle#426 does not
fix the issue for async def'd inner functions.
basnijholt pushed a commit to python-kasa/python-kasa that referenced this pull request Apr 25, 2020
This is required as PyCQA/pydocstyle#426 does not
fix the issue for async def'd inner functions.
peterjc added a commit to biopython/biopython that referenced this pull request May 9, 2020
See psf/black#709 and
PyCQA/pydocstyle#426

pydocstyle v5.0.0 (and thus flake8 D202) was
relaxed to accept the blank lines added by black.
jcristau added a commit to jcristau/scriptworker-scripts that referenced this pull request Feb 16, 2023
Once upon a time black and pydocstyle disagreed on blank lines before
nested functions, and a comment would appease them both.
Since then, the latter has been changed to not complain about a blank
line (PyCQA/pydocstyle#426), and the former now
complains about the missing blank line even with the comment
(psf/black#3302).
jcristau added a commit to jcristau/scriptworker-scripts that referenced this pull request Feb 17, 2023
Once upon a time black and pydocstyle disagreed on blank lines before
nested functions, and a comment would appease them both.
Since then, the latter has been changed to not complain about a blank
line (PyCQA/pydocstyle#426), and the former now
complains about the missing blank line even with the comment
(psf/black#3302).
jcristau added a commit to jcristau/scriptworker-scripts that referenced this pull request Feb 20, 2023
Once upon a time black and pydocstyle disagreed on blank lines before
nested functions, and a comment would appease them both.
Since then, the latter has been changed to not complain about a blank
line (PyCQA/pydocstyle#426), and the former now
complains about the missing blank line even with the comment
(psf/black#3302).
jcristau added a commit to jcristau/scriptworker-scripts that referenced this pull request Mar 6, 2023
Once upon a time black and pydocstyle disagreed on blank lines before
nested functions, and a comment would appease them both.
Since then, the latter has been changed to not complain about a blank
line (PyCQA/pydocstyle#426), and the former now
complains about the missing blank line even with the comment
(psf/black#3302).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants