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

Method __new__

Lib/_py_abc.py:35–52  ·  view source on GitHub ↗
(mcls, name, bases, namespace, /, **kwargs)

Source from the content-addressed store, hash-verified

33 _abc_invalidation_counter = 0
34
35 def __new__(mcls, name, bases, namespace, /, **kwargs):
36 cls = super().__new__(mcls, name, bases, namespace, **kwargs)
37 # Compute set of abstract method names
38 abstracts = {name
39 for name, value in namespace.items()
40 if getattr(value, "__isabstractmethod__", False)}
41 for base in bases:
42 for name in getattr(base, "__abstractmethods__", set()):
43 value = getattr(cls, name, None)
44 if getattr(value, "__isabstractmethod__", False):
45 abstracts.add(name)
46 cls.__abstractmethods__ = frozenset(abstracts)
47 # Set up inheritance registry
48 cls._abc_registry = WeakSet()
49 cls._abc_cache = WeakSet()
50 cls._abc_negative_cache = WeakSet()
51 cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter
52 return cls
53
54 def register(cls, subclass):
55 """Register a virtual subclass of an ABC.

Callers

nothing calls this directly

Calls 5

WeakSetClass · 0.90
superClass · 0.85
setFunction · 0.85
itemsMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected