-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[
pydoclint
] Add docstring-missing-returns
amd `docstring-extraneo…
…us-returns` (`DOC201`, `DOC202`) (#12485) Co-authored-by: Micha Reiser <[email protected]>
- Loading branch information
1 parent
10c993e
commit 9f72f47
Showing
13 changed files
with
609 additions
and
43 deletions.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
crates/ruff_linter/resources/test/fixtures/pydoclint/DOC201_google.py
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,73 @@ | ||
# DOC201 | ||
def foo(num: int) -> str: | ||
""" | ||
Do something | ||
Args: | ||
num (int): A number | ||
""" | ||
return 'test' | ||
|
||
|
||
# OK | ||
def foo(num: int) -> str: | ||
""" | ||
Do something | ||
Args: | ||
num (int): A number | ||
Returns: | ||
str: A string | ||
""" | ||
return 'test' | ||
|
||
|
||
class Bar: | ||
|
||
# OK | ||
def foo(self) -> str: | ||
""" | ||
Do something | ||
Args: | ||
num (int): A number | ||
Returns: | ||
str: A string | ||
""" | ||
return 'test' | ||
|
||
|
||
# DOC201 | ||
def bar(self) -> str: | ||
""" | ||
Do something | ||
Args: | ||
num (int): A number | ||
""" | ||
return 'test' | ||
|
||
|
||
# OK | ||
@property | ||
def baz(self) -> str: | ||
""" | ||
Do something | ||
Args: | ||
num (int): A number | ||
""" | ||
return 'test' | ||
|
||
|
||
# OK | ||
def test(): | ||
"""Do something.""" | ||
# DOC201 | ||
def nested(): | ||
"""Do something nested.""" | ||
return 5 | ||
|
||
print("I never return") |
76 changes: 76 additions & 0 deletions
76
crates/ruff_linter/resources/test/fixtures/pydoclint/DOC201_numpy.py
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,76 @@ | ||
# DOC201 | ||
def foo(num: int) -> str: | ||
""" | ||
Do something | ||
Parameters | ||
---------- | ||
num : int | ||
A number | ||
""" | ||
return 'test' | ||
|
||
|
||
# OK | ||
def foo(num: int) -> str: | ||
""" | ||
Do something | ||
Parameters | ||
---------- | ||
num : int | ||
A number | ||
Returns | ||
------- | ||
str | ||
A string | ||
""" | ||
return 'test' | ||
|
||
|
||
class Bar: | ||
|
||
# OK | ||
def foo(self) -> str: | ||
""" | ||
Do something | ||
Parameters | ||
---------- | ||
num : int | ||
A number | ||
Returns | ||
------- | ||
str | ||
A string | ||
""" | ||
return 'test' | ||
|
||
|
||
# DOC201 | ||
def bar(self) -> str: | ||
""" | ||
Do something | ||
Parameters | ||
---------- | ||
num : int | ||
A number | ||
""" | ||
return 'test' | ||
|
||
|
||
# OK | ||
@property | ||
def baz(self) -> str: | ||
""" | ||
Do something | ||
Parameters | ||
---------- | ||
num : int | ||
A number | ||
""" | ||
return 'test' |
50 changes: 50 additions & 0 deletions
50
crates/ruff_linter/resources/test/fixtures/pydoclint/DOC202_google.py
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,50 @@ | ||
# OK | ||
def foo(num: int) -> str: | ||
""" | ||
Do something | ||
Args: | ||
num (int): A number | ||
""" | ||
print('test') | ||
|
||
|
||
# DOC202 | ||
def foo(num: int) -> str: | ||
""" | ||
Do something | ||
Args: | ||
num (int): A number | ||
Returns: | ||
str: A string | ||
""" | ||
print('test') | ||
|
||
|
||
class Bar: | ||
|
||
# DOC202 | ||
def foo(self) -> str: | ||
""" | ||
Do something | ||
Args: | ||
num (int): A number | ||
Returns: | ||
str: A string | ||
""" | ||
print('test') | ||
|
||
|
||
# OK | ||
def bar(self) -> str: | ||
""" | ||
Do something | ||
Args: | ||
num (int): A number | ||
""" | ||
print('test') |
62 changes: 62 additions & 0 deletions
62
crates/ruff_linter/resources/test/fixtures/pydoclint/DOC202_numpy.py
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,62 @@ | ||
# OK | ||
def foo(num: int) -> str: | ||
""" | ||
Do something | ||
Parameters | ||
---------- | ||
num : int | ||
A number | ||
""" | ||
print('test') | ||
|
||
|
||
# DOC202 | ||
def foo(num: int) -> str: | ||
""" | ||
Do something | ||
Parameters | ||
---------- | ||
num : int | ||
A number | ||
Returns | ||
------- | ||
str | ||
A string | ||
""" | ||
print('test') | ||
|
||
|
||
class Bar: | ||
|
||
# DOC202 | ||
def foo(self) -> str: | ||
""" | ||
Do something | ||
Parameters | ||
---------- | ||
num : int | ||
A number | ||
Returns | ||
------- | ||
str | ||
A string | ||
""" | ||
print('test') | ||
|
||
|
||
# OK | ||
def bar(self) -> str: | ||
""" | ||
Do something | ||
Parameters | ||
---------- | ||
num : int | ||
A number | ||
""" | ||
print('test') |
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
Oops, something went wrong.