Decide whether to show documentation on a variable.
(name, all=None, obj=None)
| 324 | _future_feature_names = set(__future__.all_feature_names) |
| 325 | |
| 326 | def visiblename(name, all=None, obj=None): |
| 327 | """Decide whether to show documentation on a variable.""" |
| 328 | # Certain special names are redundant or internal. |
| 329 | # XXX Remove __initializing__? |
| 330 | if name in {'__author__', '__builtins__', '__cached__', '__credits__', |
| 331 | '__date__', '__doc__', '__file__', '__spec__', |
| 332 | '__loader__', '__module__', '__name__', '__package__', |
| 333 | '__path__', '__qualname__', '__slots__', '__version__', |
| 334 | '__static_attributes__', '__firstlineno__', |
| 335 | '__annotate_func__', '__annotations_cache__'}: |
| 336 | return 0 |
| 337 | # Private names are hidden, but special names are displayed. |
| 338 | if name.startswith('__') and name.endswith('__'): return 1 |
| 339 | # Namedtuples have public fields and methods with a single leading underscore |
| 340 | if name.startswith('_') and hasattr(obj, '_fields'): |
| 341 | return True |
| 342 | # Ignore __future__ imports. |
| 343 | if obj is not __future__ and name in _future_feature_names: |
| 344 | if isinstance(getattr(obj, name, None), __future__._Feature): |
| 345 | return False |
| 346 | if all is not None: |
| 347 | # only document that which the programmer exported in __all__ |
| 348 | return name in all |
| 349 | else: |
| 350 | return not name.startswith('_') |
| 351 | |
| 352 | def classify_class_attrs(object): |
| 353 | """Wrap inspect.classify_class_attrs, with fixup for data descriptors and bound methods.""" |
no test coverage detected