MCPcopy Index your code
hub / github.com/python/cpython / isabstract

Function isabstract

Lib/inspect.py:454–476  ·  view source on GitHub ↗

Return true if the object is an abstract base class (ABC).

(object)

Source from the content-addressed store, hash-verified

452 or isinstance(object, functools._singledispatchmethod_get))
453
454def isabstract(object):
455 """Return true if the object is an abstract base class (ABC)."""
456 if not isinstance(object, type):
457 return False
458 if object.__flags__ & TPFLAGS_IS_ABSTRACT:
459 return True
460 if not issubclass(type(object), abc.ABCMeta):
461 return False
462 if hasattr(object, '__abstractmethods__'):
463 # It looks like ABCMeta.__new__ has finished running;
464 # TPFLAGS_IS_ABSTRACT should have been accurate.
465 return False
466 # It looks like ABCMeta.__new__ has not finished running yet; we're
467 # probably in __init_subclass__. We'll look for abstractmethods manually.
468 for name, value in object.__dict__.items():
469 if getattr(value, "__isabstractmethod__", False):
470 return True
471 for base in object.__bases__:
472 for name in getattr(base, "__abstractmethods__", ()):
473 value = getattr(object, name, None)
474 if getattr(value, "__isabstractmethod__", False):
475 return True
476 return False
477
478def _getmembers(object, predicate, getter):
479 results = []

Callers 2

runtest_refleakFunction · 0.90

Calls 1

itemsMethod · 0.45

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…