Skip to content

Commit bd33f79

Browse files
Fix a crash in the docparams extension when raising the result of a function (#6767)
1 parent fa416c3 commit bd33f79

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

doc/whatsnew/2/2.14/full.rst

+2
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ Release date: TBA
9494

9595
Closes #6372
9696

97+
* Fixed a crash in the ``docparams`` extension involving raising the result of a function.
98+
9799
* Fixed failure to enable ``deprecated-module`` after a ``disable=all``
98100
by making ``ImportsChecker`` solely responsible for emitting ``deprecated-module`` instead
99101
of sharing responsibility with ``StdlibChecker``. (This could have led to double messages.)

pylint/extensions/_check_docs_utils.py

+2
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ def possible_exc_types(node: nodes.NodeNG) -> set[nodes.ClassDef]:
135135
exceptions = [target]
136136
elif isinstance(target, nodes.FunctionDef):
137137
for ret in target.nodes_of_class(nodes.Return):
138+
if ret.value is None:
139+
continue
138140
if ret.frame(future=True) != target:
139141
# return from inner function - ignore it
140142
continue

tests/extensions/test_check_docs_utils.py

+11
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,14 @@ def test_exception(raise_node, expected):
139139
for node in found_nodes:
140140
assert isinstance(node, astroid.nodes.ClassDef)
141141
assert {node.name for node in found_nodes} == expected
142+
143+
144+
def test_possible_exc_types_raising_potential_none() -> None:
145+
raise_node = astroid.extract_node(
146+
"""
147+
def a():
148+
return
149+
raise a() #@
150+
"""
151+
)
152+
assert utils.possible_exc_types(raise_node) == set()

0 commit comments

Comments
 (0)