mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
autodoc: Suppress default value for uninitialized variables
This commit is contained in:
parent
a42de07bcf
commit
6b07d8f363
@ -66,6 +66,7 @@ def identity(x: Any) -> Any:
|
||||
|
||||
|
||||
ALL = object()
|
||||
UNINITIALIZED_ATTR = object()
|
||||
INSTANCEATTR = object()
|
||||
SLOTSATTR = object()
|
||||
|
||||
@ -1348,8 +1349,11 @@ class DataDocumenter(ModuleLevelDocumenter):
|
||||
sourcename)
|
||||
|
||||
try:
|
||||
objrepr = object_description(self.object)
|
||||
self.add_line(' :value: ' + objrepr, sourcename)
|
||||
if self.object is UNINITIALIZED_ATTR:
|
||||
pass
|
||||
else:
|
||||
objrepr = object_description(self.object)
|
||||
self.add_line(' :value: ' + objrepr, sourcename)
|
||||
except ValueError:
|
||||
pass
|
||||
elif self.options.annotation is SUPPRESS:
|
||||
@ -1390,6 +1394,7 @@ class DataDeclarationDocumenter(DataDocumenter):
|
||||
"""Never import anything."""
|
||||
# disguise as a data
|
||||
self.objtype = 'data'
|
||||
self.object = UNINITIALIZED_ATTR
|
||||
try:
|
||||
# import module to obtain type annotation
|
||||
self.parent = importlib.import_module(self.modname)
|
||||
|
@ -1522,7 +1522,6 @@ def test_autodoc_typed_instance_variables(app):
|
||||
'.. py:data:: attr2',
|
||||
' :module: target.typed_vars',
|
||||
' :type: str',
|
||||
' :value: None',
|
||||
'',
|
||||
' attr2',
|
||||
'',
|
||||
|
Loading…
Reference in New Issue
Block a user