Skip to content

Commit 671f151

Browse files
authored
Fix bug in isShortDocstring (#256)
1 parent 50b0a35 commit 671f151

File tree

9 files changed

+55
-16
lines changed

9 files changed

+55
-16
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ repos:
55
- id: isort
66

77
- repo: https://github.com/jsh9/muff-pre-commit
8-
rev: 0.12.9
8+
rev: 0.12.11.1
99
hooks:
1010
- id: muff-format
1111
args: [--config, muff.toml]

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Change Log
22

3+
## [0.6.11] - 2025-08-31
4+
5+
- Fixed
6+
- A bug where short docstring is incorrectly detected
7+
- Full diff
8+
- https://github.com/jsh9/pydoclint/compare/0.6.10...0.6.11
9+
310
## [0.6.10] - 2025-08-14
411

512
- Changed

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ The corresponding Github repository of _pydoclint_ is:
6060
- [3. Style violation codes](#3-style-violation-codes)
6161
- [4. Additional notes for users](#4-additional-notes-for-users)
6262
- [5. Notes for developers](#5-notes-for-developers)
63-
- [6. Miscellaneous notes](#6-miscellaneous-notes)
6463

6564
<!--TOC-->
6665

@@ -214,6 +213,14 @@ For detailed explanations of each violation code, please read this page:
214213

215214
## 4. Additional notes for users
216215

216+
Here are some additional notes to help you use _pydoclint_ more easily:
217+
218+
- [Notes for users](https://jsh9.github.io/pydoclint/notes_for_users.html)
219+
- (Contains frequently encountered issues)
220+
- [Checking class attributes](https://jsh9.github.io/pydoclint/checking_class_attributes.html)
221+
- [Notes on `Generator` vs `Iterator`](https://jsh9.github.io/pydoclint/notes_generator_vs_iterator.html)
222+
- [More about docstring style mismatch (`DOC003`)](https://jsh9.github.io/pydoclint/style_mismatch.html)
223+
217224
If you'd like to use _pydoclint_ for your project, it is recommended that you
218225
read these additional notes
219226
[here](https://jsh9.github.io/pydoclint/notes_for_users.html).
@@ -227,9 +234,3 @@ If you'd like to contribute to the code base of _pydoclint_, thank you!
227234

228235
[This guide](https://jsh9.github.io/pydoclint/notes_for_developers.html) can
229236
hopefully help you get familiar with the code base faster.
230-
231-
## 6. Miscellaneous notes
232-
233-
- [Checking class attributes](https://jsh9.github.io/pydoclint/checking_class_attributes.html)
234-
- [Notes on `Generator` vs `Iterator`](https://jsh9.github.io/pydoclint/notes_generator_vs_iterator.html)
235-
- [More about docstring style mismatch (`DOC003`)](https://jsh9.github.io/pydoclint/style_mismatch.html)

docs/index.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ The corresponding Github repository of _pydoclint_ is:
6060
- [3. Style violation codes](#3-style-violation-codes)
6161
- [4. Additional notes for users](#4-additional-notes-for-users)
6262
- [5. Notes for developers](#5-notes-for-developers)
63-
- [6. Miscellaneous notes](#6-miscellaneous-notes)
6463

6564
<!--TOC-->
6665

@@ -214,6 +213,14 @@ For detailed explanations of each violation code, please read this page:
214213

215214
## 4. Additional notes for users
216215

216+
Here are some additional notes to help you use _pydoclint_ more easily:
217+
218+
- [Notes for users](https://jsh9.github.io/pydoclint/notes_for_users.html)
219+
- (Contains frequently encountered issues)
220+
- [Checking class attributes](https://jsh9.github.io/pydoclint/checking_class_attributes.html)
221+
- [Notes on `Generator` vs `Iterator`](https://jsh9.github.io/pydoclint/notes_generator_vs_iterator.html)
222+
- [More about docstring style mismatch (`DOC003`)](https://jsh9.github.io/pydoclint/style_mismatch.html)
223+
217224
If you'd like to use _pydoclint_ for your project, it is recommended that you
218225
read these additional notes
219226
[here](https://jsh9.github.io/pydoclint/notes_for_users.html).
@@ -227,9 +234,3 @@ If you'd like to contribute to the code base of _pydoclint_, thank you!
227234

228235
[This guide](https://jsh9.github.io/pydoclint/notes_for_developers.html) can
229236
hopefully help you get familiar with the code base faster.
230-
231-
## 6. Miscellaneous notes
232-
233-
- [Checking class attributes](https://jsh9.github.io/pydoclint/checking_class_attributes.html)
234-
- [Notes on `Generator` vs `Iterator`](https://jsh9.github.io/pydoclint/notes_generator_vs_iterator.html)
235-
- [More about docstring style mismatch (`DOC003`)](https://jsh9.github.io/pydoclint/style_mismatch.html)

pydoclint/utils/doc.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ def isShortDocstring(self) -> bool: # type:ignore[return]
5858
and len(self.parsed.raises) == 0
5959
and self.parsed.returns is None
6060
and len(self.parsed.many_returns) == 0
61+
and self.parsed.yields is None
62+
and len(self.parsed.many_yields) == 0
6163
and len(self.parsed.examples) == 0
6264
and self.parsed.deprecation is None
6365
)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "pydoclint"
7-
version = "0.6.10"
7+
version = "0.6.11"
88
description = "A Python docstring linter that checks arguments, returns, yields, and raises sections"
99
readme = "README.md"
1010
license = {text = "MIT"}

requirements.dev

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
tox
2+
pytest
3+
pre-commit
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# From https://github.com/jsh9/pydoclint/issues/254
2+
3+
def test_yield_with_typing_no_args() -> Generator[typing.Any]:
4+
"""
5+
Testing the behaviour of pydoclint with a function which has specified the Generator via
6+
the typing module and has no arguments
7+
8+
Yields:
9+
Generator123[typing.Any]: An iterable argument
10+
11+
"""
12+
yield [1]

tests/test_main.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1942,6 +1942,19 @@ def testNonAscii() -> None:
19421942
'"google" style, but the docstring is likely not written in this style.',
19431943
],
19441944
),
1945+
(
1946+
'29_yields_section/case.py',
1947+
{
1948+
'style': 'google',
1949+
'skipCheckingShortDocstrings': True,
1950+
},
1951+
[
1952+
'DOC404: Function `test_yield_with_typing_no_args` yield type(s) in docstring '
1953+
'not consistent with the return annotation. The yield type (the 0th arg in '
1954+
'Generator[...]/Iterator[...]): Generator[typing.Any]; docstring "yields" '
1955+
'section types: Generator123[typing.Any]'
1956+
],
1957+
),
19451958
],
19461959
)
19471960
def testEdgeCases(

0 commit comments

Comments
 (0)