Skip to content

Commit 9c7e19c

Browse files
romanlutzbiefanCopilot
authored
MAINT: Document D421 property-docstring noun-phrase convention (microsoft#2102)
Co-authored-by: biefan <70761325+biefan@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 726e933 commit 9c7e19c

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

.github/instructions/style-guide.instructions.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,10 +481,19 @@ async def temporary_config(self, **kwargs):
481481
### Property Decorators
482482
- Use @property for simple computed attributes
483483
- Use explicit getter/setter methods for complex logic
484+
- Property docstrings must be **noun phrases** describing the value (e.g.
485+
`"""The display name."""`), not verb phrases (e.g. `"""Return the display
486+
name."""`). This is enforced by Ruff `D421` (property-docstring-starts-with-verb).
484487

485488
```python
486489
# CORRECT
487490
@property
491+
def is_complete(self) -> bool:
492+
"""Whether the attack is complete."""
493+
return self._status == AttackStatus.COMPLETE
494+
495+
# INCORRECT - verb-phrase docstring, flagged by Ruff D421
496+
@property
488497
def is_complete(self) -> bool:
489498
"""Check if the attack is complete."""
490499
return self._status == AttackStatus.COMPLETE

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,9 @@ select = [
324324
"B", # https://docs.astral.sh/ruff/rules/#flake8-bugbear-b
325325
"C4", # https://docs.astral.sh/ruff/rules/#flake8-comprehensions-c4
326326
"CPY001", # missing-copyright-notice
327+
# "D" + preview=true enables D421 (property-docstring-starts-with-verb):
328+
# property docstrings must be noun phrases ("""The display name."""), not
329+
# verb phrases ("""Return the display name."""). Keep "D" selected, not ignored.
327330
"D", # https://docs.astral.sh/ruff/rules/#pydocstyle-d
328331
"DOC", # https://docs.astral.sh/ruff/rules/#pydoclint-doc
329332
"DTZ", # https://docs.astral.sh/ruff/rules/#flake8-datetimez-dtz

0 commit comments

Comments
 (0)