This repository has been archived by the owner on Nov 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(checker): allow whitespace before inner functions and class (#426)
* fix(checker): allow whitespace before inner functions and class 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. * fix(checker): use raw string for all regex Avoid DeprecationWarning ("invalid escape sequence").
- Loading branch information
1 parent
4aa5d96
commit a1a4d0b
Showing
4 changed files
with
68 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
"""A valid module docstrings.""" | ||
|
||
from .expected import Expectation | ||
|
||
expectation = Expectation() | ||
expect = expectation.expect | ||
|
||
|
||
@expect("D201: No blank lines allowed before function docstring (found 1)") | ||
def func_with_space_before(): | ||
|
||
"""Test a function with space before docstring.""" | ||
pass | ||
|
||
|
||
@expect("D202: No blank lines allowed after function docstring (found 1)") | ||
def func_with_space_after(): | ||
"""Test a function with space after docstring.""" | ||
|
||
pass | ||
|
||
|
||
def func_with_inner_func_after(): | ||
"""Test a function with inner function after docstring.""" | ||
|
||
def inner(): | ||
pass | ||
|
||
pass | ||
|
||
|
||
def fake_decorator(decorated): | ||
"""Fake decorator used to test decorated inner func.""" | ||
return decorated | ||
|
||
|
||
def func_with_inner_decorated_func_after(): | ||
"""Test a function with inner decorated function after docstring.""" | ||
|
||
@fake_decorator | ||
def inner(): | ||
pass | ||
|
||
pass | ||
|
||
|
||
def func_with_inner_class_after(): | ||
"""Test a function with inner class after docstring.""" | ||
|
||
class inner(): | ||
pass | ||
|
||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters