mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
refactor: AttributeError handling for getslots() is not needed
This commit is contained in:
parent
9c56224231
commit
42e491a4c2
@ -2226,7 +2226,7 @@ class SlotsMixin(DataDocumenterMixinBase):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
except (AttributeError, ValueError, TypeError):
|
||||
except (ValueError, TypeError):
|
||||
return False
|
||||
|
||||
def import_object(self, raiseerror: bool = False) -> bool:
|
||||
@ -2252,7 +2252,7 @@ class SlotsMixin(DataDocumenterMixinBase):
|
||||
return [docstring]
|
||||
else:
|
||||
return []
|
||||
except (AttributeError, ValueError) as exc:
|
||||
except ValueError as exc:
|
||||
logger.warning(__('Invalid __slots__ found on %s. Ignored.'),
|
||||
(self.parent.__qualname__, exc), type='autodoc')
|
||||
return []
|
||||
|
@ -211,7 +211,7 @@ def get_object_members(subject: Any, objpath: List[str], attrgetter: Callable,
|
||||
|
||||
for name in __slots__:
|
||||
members[name] = Attribute(name, True, SLOTSATTR)
|
||||
except (AttributeError, TypeError, ValueError):
|
||||
except (TypeError, ValueError):
|
||||
pass
|
||||
|
||||
# other members
|
||||
@ -273,7 +273,7 @@ def get_class_members(subject: Any, objpath: List[str], attrgetter: Callable
|
||||
for name, docstring in __slots__.items():
|
||||
members[name] = ObjectMember(name, SLOTSATTR, class_=subject,
|
||||
docstring=docstring)
|
||||
except (AttributeError, TypeError, ValueError):
|
||||
except (TypeError, ValueError):
|
||||
pass
|
||||
|
||||
# other members
|
||||
|
@ -179,7 +179,6 @@ def getslots(obj: Any) -> Optional[Dict]:
|
||||
"""Get __slots__ attribute of the class as dict.
|
||||
|
||||
Return None if gienv *obj* does not have __slots__.
|
||||
Raises AttributeError if given *obj* raises an error on accessing __slots__.
|
||||
Raises TypeError if given *obj* is not a class.
|
||||
Raises ValueError if given *obj* have invalid __slots__.
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user