Skip to content

Commit 3fe01c3

Browse files
authored
Merge pull request #9507 from tk0miya/9479_autodoc_mocked_target
Fix #9479: autodoc: Emit a warning if target is a mocked object
2 parents 383eff0 + 33f70be commit 3fe01c3

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Features added
1414
--------------
1515

1616
* #9445: autodoc: Support class properties
17+
* #9479: autodoc: Emit a warning if target is a mocked object
1718
* #9445: py domain: ``:py:property:`` directive supports ``:classmethod:``
1819
option to describe the class property
1920

sphinx/ext/autodoc/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,10 @@ def generate(self, more_content: Optional[StringList] = None, real_modname: str
913913
if not self.import_object():
914914
return
915915

916+
if ismock(self.object):
917+
logger.warning(__('A mocked object is detected: %r'),
918+
self.name, type='autodoc')
919+
916920
# If there is no real module defined, figure out which to use.
917921
# The real module is used in the module analyzer to look up the module
918922
# where the attribute documentation would actually be found in.

0 commit comments

Comments
 (0)