MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / add_metaclass

Function add_metaclass

pager_lib/six.py:885–900  ·  view source on GitHub ↗

Class decorator for creating a class with a metaclass.

(metaclass)

Source from the content-addressed store, hash-verified

883
884
885def add_metaclass(metaclass):
886 """Class decorator for creating a class with a metaclass."""
887 def wrapper(cls):
888 orig_vars = cls.__dict__.copy()
889 slots = orig_vars.get('__slots__')
890 if slots is not None:
891 if isinstance(slots, str):
892 slots = [slots]
893 for slots_var in slots:
894 orig_vars.pop(slots_var)
895 orig_vars.pop('__dict__', None)
896 orig_vars.pop('__weakref__', None)
897 if hasattr(cls, '__qualname__'):
898 orig_vars['__qualname__'] = cls.__qualname__
899 return metaclass(cls.__name__, cls.__bases__, orig_vars)
900 return wrapper
901
902
903def ensure_binary(s, encoding='utf-8', errors='strict'):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected