Skip to content

Commit

Permalink
Move new sections to the end
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Feb 8, 2024
1 parent c53fdb0 commit ed05447
Show file tree
Hide file tree
Showing 8 changed files with 325 additions and 317 deletions.
63 changes: 32 additions & 31 deletions crates/ruff_linter/resources/test/fixtures/pydocstyle/sections.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,25 +428,6 @@ def test_method(self, test, another_test, z, _, x=1, y=2, _private_arg=1): # no
"""

def test_method_should_be_correctly_capitalized(self, parameters: list[str], other_parameters: dict[str, str]): # noqa: D213
"""Test parameters and attributes sections are capitalized correctly.
Parameters
----------
parameters:
A list of string parameters
other_parameters:
A dictionary of string attributes
Other Parameters
----------
other_parameters:
A dictionary of string attributes
parameters:
A list of string parameters
"""

@expect("D417: Missing argument descriptions in the docstring "
"(argument(s) test, y, z are missing descriptions in "
"'test_missing_args' docstring)", arg_count=5)
Expand Down Expand Up @@ -507,18 +488,6 @@ def test_mixing_numpy_and_google(danger): # noqa: D213
"""

@staticmethod
def test_lowercase_sub_section_header_should_be_valid(parameters: list[str], value: int): # noqa: D213
"""Test that lower case sub-section header is valid even if it has the same name as section kind.
Parameters:
----------
parameters:
A list of string parameters
value:
Some value
"""


class TestIncorrectIndent: # noqa: D203
"""Test class."""
Expand Down Expand Up @@ -593,3 +562,35 @@ def titlecase_sub_section_header():
Returns:
"""


def test_method_should_be_correctly_capitalized(self, parameters: list[str], other_parameters: dict[str, str]): # noqa: D213
"""Test parameters and attributes sections are capitalized correctly.
Parameters
----------
parameters:
A list of string parameters
other_parameters:
A dictionary of string attributes
Other Parameters
----------
other_parameters:
A dictionary of string attributes
parameters:
A list of string parameters
"""


def test_lowercase_sub_section_header_should_be_valid(parameters: list[str], value: int): # noqa: D213
"""Test that lower case sub-section header is valid even if it has the same name as section kind.
Parameters:
----------
parameters:
A list of string parameters
value:
Some value
"""
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,29 @@ sections.py:144:5: D214 [*] Section is over-indented ("Returns")
148 148 | A value of some sort.
149 149 |

sections.py:589:5: D214 [*] Section is over-indented ("Returns")
sections.py:558:5: D214 [*] Section is over-indented ("Returns")
|
588 | def titlecase_sub_section_header():
589 | """Below, `Returns:` should be considered a section header.
557 | def titlecase_sub_section_header():
558 | """Below, `Returns:` should be considered a section header.
| _____^
590 | |
591 | | Args:
592 | | Here's a note.
593 | |
594 | | Returns:
595 | | """
559 | |
560 | | Args:
561 | | Here's a note.
562 | |
563 | | Returns:
564 | | """
| |_______^ D214
|
= help: Remove over-indentation from "Returns"

Safe fix
591 591 | Args:
592 592 | Here's a note.
593 593 |
594 |- Returns:
594 |+ Returns:
595 595 | """
560 560 | Args:
561 561 | Here's a note.
562 562 |
563 |- Returns:
563 |+ Returns:
564 564 | """
565 565 |
566 566 |


Original file line number Diff line number Diff line change
Expand Up @@ -61,32 +61,31 @@ sections.py:216:5: D406 [*] Section name should end with a newline ("Raises")
229 229 |
230 230 | """

sections.py:512:9: D406 [*] Section name should end with a newline ("Parameters")
sections.py:588:5: D406 [*] Section name should end with a newline ("Parameters")
|
510 | @staticmethod
511 | def test_lowercase_sub_section_header_should_be_valid(parameters: list[str], value: int): # noqa: D213
512 | """Test that lower case sub-section header is valid even if it has the same name as section kind.
| _________^
513 | |
514 | | Parameters:
515 | | ----------
516 | | parameters:
517 | | A list of string parameters
518 | | value:
519 | | Some value
520 | | """
| |___________^ D406
587 | def test_lowercase_sub_section_header_should_be_valid(parameters: list[str], value: int): # noqa: D213
588 | """Test that lower case sub-section header is valid even if it has the same name as section kind.
| _____^
589 | |
590 | | Parameters:
591 | | ----------
592 | | parameters:
593 | | A list of string parameters
594 | | value:
595 | | Some value
596 | | """
| |_______^ D406
|
= help: Add newline after "Parameters"

ℹ Safe fix
511 511 | def test_lowercase_sub_section_header_should_be_valid(parameters: list[str], value: int): # noqa: D213
512 512 | """Test that lower case sub-section header is valid even if it has the same name as section kind.
513 513 |
514 |- Parameters:
514 |+ Parameters
515 515 | ----------
516 516 | parameters:
517 517 | A list of string parameters
587 587 | def test_lowercase_sub_section_header_should_be_valid(parameters: list[str], value: int): # noqa: D213
588 588 | """Test that lower case sub-section header is valid even if it has the same name as section kind.
589 589 |
590 |- Parameters:
590 |+ Parameters
591 591 | ----------
592 592 | parameters:
593 593 | A list of string parameters


Loading

0 comments on commit ed05447

Please sign in to comment.