Skip to content

Commit e4bea83

Browse files
committed
Clean up exceptions and conditionals
1 parent 2365af0 commit e4bea83

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

sphinx_automodapi/autodoc_enhancements.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,12 @@ def type_object_attrgetter(obj, attr, *defargs):
6262

6363
try:
6464
return getattr(obj, attr, *defargs)
65-
except AttributeError as e:
65+
except AttributeError:
6666
# for dataclasses, get the attribute from the __dataclass_fields__
67-
if dataclasses.is_dataclass(obj):
68-
if attr in obj.__dataclass_fields__:
69-
return obj.__dataclass_fields__[attr].name
70-
else:
71-
# raise original AttributeError
72-
raise e
67+
if dataclasses.is_dataclass(obj) and attr in obj.__dataclass_fields__:
68+
return obj.__dataclass_fields__[attr].name
7369
else:
74-
# raise original AttributeError
75-
raise e
70+
raise
7671

7772

7873
def setup(app):

0 commit comments

Comments
 (0)