Lines Matching refs:cls
133 cls = super().__new__(mcls, name, bases, namespace)
140 value = getattr(cls, name, None)
143 cls.__abstractmethods__ = frozenset(abstracts)
145 cls._abc_registry = WeakSet()
146 cls._abc_cache = WeakSet()
147 cls._abc_negative_cache = WeakSet()
148 cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter
149 return cls
151 def register(cls, subclass): argument
158 if issubclass(subclass, cls):
162 if issubclass(cls, subclass):
165 cls._abc_registry.add(subclass)
169 def _dump_registry(cls, file=None): argument
171 print("Class: %s.%s" % (cls.__module__, cls.__qualname__), file=file)
173 for name in sorted(cls.__dict__.keys()):
175 value = getattr(cls, name)
178 def __instancecheck__(cls, instance): argument
182 if subclass in cls._abc_cache:
186 if (cls._abc_negative_cache_version ==
188 subclass in cls._abc_negative_cache):
191 return cls.__subclasscheck__(subclass)
192 return any(cls.__subclasscheck__(c) for c in {subclass, subtype})
194 def __subclasscheck__(cls, subclass): argument
197 if subclass in cls._abc_cache:
200 if cls._abc_negative_cache_version < ABCMeta._abc_invalidation_counter:
202 cls._abc_negative_cache = WeakSet()
203 cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter
204 elif subclass in cls._abc_negative_cache:
207 ok = cls.__subclasshook__(subclass)
211 cls._abc_cache.add(subclass)
213 cls._abc_negative_cache.add(subclass)
216 if cls in getattr(subclass, '__mro__', ()):
217 cls._abc_cache.add(subclass)
220 for rcls in cls._abc_registry:
222 cls._abc_cache.add(subclass)
225 for scls in cls.__subclasses__():
227 cls._abc_cache.add(subclass)
230 cls._abc_negative_cache.add(subclass)