Skip to content

Commit 1a6a73a

Browse files
committed
Fix undocumented class attribute (#165)
1 parent 315d1e8 commit 1a6a73a

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

docs/src/release_notes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ sphinx-codeautolink adheres to
1414
where reference documentation does not appear to have
1515
a corresponding tutorial or how-to (:issue:`161`)
1616
- Add more Pygments lexer aliases in code blocks (:issue:`160`)
17+
- Fix undocumented class attribute leading to a crash (:issue:`165`)
1718

1819
0.16.2 (2025-01-16)
1920
-------------------

src/sphinx_codeautolink/extension/resolve.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,9 @@ def locate_type(cursor: Cursor, components: tuple[str, ...], inventory) -> Curso
8686
with suppress(AttributeError, TypeError):
8787
cursor.location = fully_qualified_name(cursor.value)
8888

89+
# Check bases if member not found in current class
8990
if isclass(previous.value) and cursor.location not in inventory:
90-
for val in previous.value.__mro__:
91+
for val in previous.value.__mro__[1:]:
9192
name = fully_qualified_name(val)
9293
if name + "." + component in inventory:
9394
previous.location = name
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class_mro_fix
2+
Parameter
3+
# split
4+
codeautolink_warn_on_missing_inventory = False
5+
# split
6+
Test project
7+
============
8+
9+
.. code:: python
10+
11+
from class_mro_fix import Parameter
12+
13+
Parameter.empty
14+
15+
.. automodule:: class_mro_fix
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# noqa: INP001
2+
# Test an edge case that happens in the inspect module, see #165 for details
3+
4+
5+
class _empty: # noqa: N801
6+
pass
7+
8+
9+
class Parameter:
10+
empty = _empty

0 commit comments

Comments
 (0)