(obj, config: InspectConfig)
| 107 | |
| 108 | |
| 109 | def _iter_attributes(obj, config: InspectConfig) -> Iterable[InspectAttribute]: |
| 110 | for key in dir(obj): |
| 111 | dunder = key.startswith('__') and key.endswith('__') |
| 112 | if dunder and not config.dunder: |
| 113 | continue |
| 114 | private = key.startswith('_') and not dunder |
| 115 | try: |
| 116 | value = getattr(obj, key) |
| 117 | except BaseException as e: |
| 118 | value = e |
| 119 | _callable = callable(value) |
| 120 | signature = _get_callable_signature(key, value) if _callable else None |
| 121 | doc = _get_doc(value, long=config.long) if _callable else None |
| 122 | yield InspectAttribute( |
| 123 | name=key, value=value, type=type(value), callable=_callable, dunder=dunder, |
| 124 | private=private, signature=signature, doc=doc, |
| 125 | ) |
| 126 | |
| 127 | |
| 128 | def _get_callable_signature(name: str, obj) -> str: |
no test coverage detected