-
Notifications
You must be signed in to change notification settings - Fork 2k
DOC403 behaviour with yielding none #13001
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't workingdocstringRelated to docstring linting or formattingRelated to docstring linting or formattinggood first issueGood for newcomersGood for newcomerspreviewRelated to preview mode featuresRelated to preview mode features
Description
- List of keywords you searched for before creating this issue. Write them down here so that others can find this issue more easily and help provide feedback.
"DOC403 ", "numpydoc", "yields" - A minimal code snippet that reproduces the bug.
@pytest.fixture
def db_setup() -> Generator[None, None, None]:
"""
Add test user.
Yields
------
And then cleans up test user.
"""
database = Database('my_database_url')
with database.create_session() as session:
session.execute(insert(database.Users, [{'id': 1, 'name': 'Bob'}
yield
with database.create_session() as session:
session.execute(delete(database.Users).where(database.Users.id == 1234)
- The command you invoked (e.g.,
ruff /path/to/file.py --fix), ideally including the--isolatedflag.
ruff /path/to/file.py --fix - The current Ruff settings (any relevant sections from your
pyproject.toml).
[tool.ruff]
line-length = 120
preview = true
target-version = 'py312'
[tool.ruff.format]
line-ending = 'lf'
quote-style = 'single'
[tool.ruff.lint]
extend-select = ['D213']
ignore = ['ANN401', 'CPY001', 'D107', 'D203', 'D212', 'E203', 'ISC003', 'PLC1901', 'PLR6104']
select = ['ALL']
[tool.ruff.lint.flake8-implicit-str-concat]
allow-multiline = false
[tool.ruff.lint.flake8-quotes]
inline-quotes = 'single'
[tool.ruff.lint.flake8-type-checking]
strict = true
[tool.ruff.lint.pydocstyle]
convention = 'numpy'
[tool.ruff.lint.pylint]
max-args = 14
max-statements = 75
- The current Ruff version (
ruff --version).
ruff 0.6.1
The above code snippet results in a DOC403 Docstring has a "Yields" section but the function doesn't yield anything.
If the yields section is removed from the docstring then numpydoc-validation reports:
+---------------------+-------------------+---------+-------------------------+
| file | item | check | description |
+=====================+===================+=========+=========================+
| src/conftest.py:135 | conftest.db_setup | YD01 | No Yields section found |
+---------------------+-------------------+---------+-------------------------+
I understand that it is debatable about what the docstring should be a for a yield statement that yields None, but I think ruff should probably match the numpydoc-validator tool in this case.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingdocstringRelated to docstring linting or formattingRelated to docstring linting or formattinggood first issueGood for newcomersGood for newcomerspreviewRelated to preview mode featuresRelated to preview mode features