Decide whether to show documentation on a variable.
(name, all=None, obj=None)
| 259 | _future_feature_names = set(__future__.all_feature_names) |
| 260 | |
| 261 | def visiblename(name, all=None, obj=None): |
| 262 | """Decide whether to show documentation on a variable.""" |
| 263 | # Certain special names are redundant or internal. |
| 264 | # XXX Remove __initializing__? |
| 265 | if name in {'__author__', '__builtins__', '__credits__', '__date__', |
| 266 | '__doc__', '__file__', '__spec__', '__loader__', '__module__', |
| 267 | '__name__', '__package__', '__path__', '__qualname__', |
| 268 | '__slots__', '__version__', '__static_attributes__', |
| 269 | '__firstlineno__', '__annotate_func__', |
| 270 | '__annotations_cache__'}: |
| 271 | return 0 |
| 272 | # Private names are hidden, but special names are displayed. |
| 273 | if name.startswith('__') and name.endswith('__'): return 1 |
| 274 | # Namedtuples have public fields and methods with a single leading underscore |
| 275 | if name.startswith('_') and hasattr(obj, '_fields'): |
| 276 | return True |
| 277 | # Ignore __future__ imports. |
| 278 | if obj is not __future__ and name in _future_feature_names: |
| 279 | if isinstance(getattr(obj, name, None), __future__._Feature): |
| 280 | return False |
| 281 | if all is not None: |
| 282 | # only document that which the programmer exported in __all__ |
| 283 | return name in all |
| 284 | else: |
| 285 | return not name.startswith('_') |
| 286 | |
| 287 | def classify_class_attrs(object): |
| 288 | """Wrap inspect.classify_class_attrs, with fixup for data descriptors and bound methods.""" |