8000 Don't treat name of field as default value · astropy/sphinx-automodapi@ec44299 · GitHub
[go: up one dir, main page]

Skip to content

Commit ec44299

Browse files
committed
Don't treat name of field as default value
1 parent e4bea83 commit ec44299

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

sphinx_automodapi/autodoc_enhancements.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def type_object_attrgetter(obj, attr, *defargs):
6565
except AttributeError:
6666
# for dataclasses, get the attribute from the __dataclass_fields__
6767
if dataclasses.is_dataclass(obj) and attr in obj.__dataclass_fields__:
68-
return obj.__dataclass_fields__[attr].name
68+
return obj.__dataclass_fields__[attr].default
6969
else:
7070
raise
7171

sphinx_automodapi/tests/test_autodoc_enhancements.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,5 @@ class MyDataclass:
5656

5757
with pytest.raises(AttributeError):
5858
getattr(MyDataclass, 'foo')
59-
assert type_object_attrgetter(MyDataclass, 'foo') == 'foo'
59+
assert type_object_attrgetter(MyDataclass, 'foo') == dataclasses.MISSING
6060
assert getattr(MyDataclass, 'bar') == 'bar value'

0 commit comments

Comments
 (0)
0