diff --git a/CHANGES b/CHANGES index 3abf392d2..be52ee3db 100644 --- a/CHANGES +++ b/CHANGES @@ -14,6 +14,7 @@ Features added -------------- * #9445: autodoc: Support class properties +* #9479: autodoc: Emit a warning if target is a mocked object * #9445: py domain: ``:py:property:`` directive supports ``:classmethod:`` option to describe the class property diff --git a/sphinx/ext/autodoc/__init__.py b/sphinx/ext/autodoc/__init__.py index 12a505fda..938f976cd 100644 --- a/sphinx/ext/autodoc/__init__.py +++ b/sphinx/ext/autodoc/__init__.py @@ -913,6 +913,10 @@ class Documenter: if not self.import_object(): return + if ismock(self.object): + logger.warning(__('A mocked object is detected: %r'), + self.name, type='autodoc') + # If there is no real module defined, figure out which to use. # The real module is used in the module analyzer to look up the module # where the attribute documentation would actually be found in.