Skip to content

Commit 7100b39

Browse files
dhermesPCManticore
authored andcommitted
Allow a . as a prefix for Sphinx name resolution. (#3058)
For context see #1502 (comment) In this issue it was agreed that `re.error`, `~re.error` and `!re.error` would all be accepted. However, it's also common in Sphinx to use a `.` prefix for local references.
1 parent a6b1e81 commit 7100b39

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

CONTRIBUTORS.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,3 +315,5 @@ contributors:
315315
* Andrés Pérez Hortal: contributor
316316

317317
* Niko Wenselowski: contributor
318+
319+
* Danny Hermes: contributor

ChangeLog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,8 @@ Release date: TBA
223223

224224
* Changed description of W0199 to use the term 2-item-tuple instead of 2-uple.
225225

226+
* Allow a `.` as a prefix for Sphinx name resolution.
227+
226228

227229
What's New in Pylint 2.3.0?
228230
===========================

pylint/extensions/_check_docs_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def params_documented_elsewhere(self):
230230

231231
class SphinxDocstring(Docstring):
232232
re_type = r"""
233-
[~!]? # Optional link style prefix
233+
[~!.]? # Optional link style prefix
234234
\w(?:\w|\.[^\.])* # Valid python name
235235
"""
236236

tests/extensions/test_check_raise_docs.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,24 @@ def my_func(self):
167167
with self.assertNoMessages():
168168
self.checker.visit_raise(raise_node)
169169

170+
def test_google_raises_local_reference(self):
171+
raise_node = astroid.extract_node(
172+
'''
173+
def my_func(self):
174+
"""This is a google docstring.
175+
176+
Raises:
177+
.LocalException: Always
178+
"""
179+
from neighbor_module import LocalException
180+
raise LocalException('hi') #@
181+
'''
182+
)
183+
# pylint allows this to pass since the comparison between Raises and
184+
# raise are based on the class name, not the qualified name.
185+
with self.assertNoMessages():
186+
self.checker.visit_raise(raise_node)
187+
170188
@set_config(accept_no_raise_doc=False)
171189
def test_google_raises_with_prefix(self):
172190
code_snippet = '''

0 commit comments

Comments
 (0)