Skip to content

Commit d0d5c91

Browse files
[pointless-string-statement] Ignore docstrings on py3.12 type aliases (#9269) (#9287)
(cherry picked from commit 796eae3) Co-authored-by: Jacob Walls <[email protected]>
1 parent 81f0f2e commit d0d5c91

File tree

5 files changed

+17
-1
lines changed

5 files changed

+17
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- `Discussion thread re: docstrings on assignments <https://discuss.python.org/t/docstrings-for-new-type-aliases-as-defined-in-pep-695/39816>`_
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Fixed ``pointless-string-statement`` false positive for docstrings
2+
on Python 3.12 type aliases.
3+
4+
Closes #9268

pylint/checkers/base/basic_checker.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,9 @@ def visit_expr(self, node: nodes.Expr) -> None:
446446
if (
447447
sibling is not None
448448
and sibling.scope() is scope
449-
and isinstance(sibling, (nodes.Assign, nodes.AnnAssign))
449+
and isinstance(
450+
sibling, (nodes.Assign, nodes.AnnAssign, nodes.TypeAlias)
451+
)
450452
):
451453
return
452454
self.add_message("pointless-string-statement", node=node)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
"""Move this into statement_without_effect.py when python 3.12 is minimum."""
2+
3+
type MyTuple = tuple[str, str]
4+
"""
5+
Multiline docstring
6+
for Python3.12 type alias (PEP 695)
7+
"""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[testoptions]
2+
min_pyver=3.12

0 commit comments

Comments
 (0)