
class _FormatterMeta(type):
    registry = {}

    def __new__(mcls, name, bases, members):
        if 'name' in members:
            formatter_name = members['name'].lower()
        else:
            formatter_name = members['name'] = name.lower()

        cls = super().__new__(mcls, name, bases, members)

        mcls.registry[formatter_name] = cls

        return cls


class Base(metaclass=_FormatterMeta):
    """
    The abstract base class of all unit formats.
    """

    def __new__(cls, *args, **kwargs):
        # This __new__ is to make it clear that there is no reason to
        # instantiate a Formatter--if you try to you'll just get back the
        # class
        return cls

    @classmethod
    def parse(cls, s):
        """
        Convert a string to a unit object.
        """

        raise NotImplementedError(
            f"Can not parse with {cls.__name__} format")

    @classmethod
    def to_string(cls, u):
        """
        Convert a unit object to a string.
        """

        raise NotImplementedError(
            f"Can not output in {cls.__name__} format")


class Base:
    """
    The abstract base class of all unit formats.
    """
    registry = {}

    def __new__(cls, *args, **kwargs):
        # This __new__ is to make it clear that there is no reason to
        # instantiate a Formatter--if you try to you'll just get back the
        # class
        return cls

    def __init_subclass__(cls, **kwargs):
        # Keep a registry of all formats.  Key by the class name unless a name
        # is explicitly set (i.e., one *not* inherited from a superclass).
        if 'name' not in cls.__dict__:
            cls.name = cls.__name__.lower()

        Base.registry[cls.name] = cls
        super().__init_subclass__(**kwargs)

    @classmethod
    def parse(cls, s):
        """
        Convert a string to a unit object.
        """

        raise NotImplementedError(
            f"Can not parse with {cls.__name__} format")

    @classmethod
    def to_string(cls, u):
        """
        Convert a unit object to a string.
        """

        raise NotImplementedError(
            f"Can not output in {cls.__name__} format")

Remove use of metaclass for unit formats
Remove use of metaclass for unit formats

  
+ class Base:
- class _FormatterMeta(type):
-     registry = {}
- 
-     def __new__(mcls, name, bases, members):
-         if 'name' in members:
-             formatter_name = members['name'].lower()
-         else:
-             formatter_name = members['name'] = name.lower()
- 
-         cls = super().__new__(mcls, name, bases, members)
- 
-         mcls.registry[formatter_name] = cls
- 
-         return cls
- 
- 
- class Base(metaclass=_FormatterMeta):
      """
      The abstract base class of all unit formats.
      """
+     registry = {}
  
      def __new__(cls, *args, **kwargs):
          # This __new__ is to make it clear that there is no reason to
          # instantiate a Formatter--if you try to you'll just get back the
          # class
          return cls
+ 
+     def __init_subclass__(cls, **kwargs):
+         # Keep a registry of all formats.  Key by the class name unless a name
+         # is explicitly set (i.e., one *not* inherited from a superclass).
+         if 'name' not in cls.__dict__:
+             cls.name = cls.__name__.lower()
+ 
+         Base.registry[cls.name] = cls
+         super().__init_subclass__(**kwargs)
  
      @classmethod
      def parse(cls, s):
          """
          Convert a string to a unit object.
          """
  
          raise NotImplementedError(
              f"Can not parse with {cls.__name__} format")
  
      @classmethod
      def to_string(cls, u):
          """
          Convert a unit object to a string.
          """
  
          raise NotImplementedError(
              f"Can not output in {cls.__name__} format")
  
Remove use of metaclass for unit formats
## Code Before:

class _FormatterMeta(type):
    registry = {}

    def __new__(mcls, name, bases, members):
        if 'name' in members:
            formatter_name = members['name'].lower()
        else:
            formatter_name = members['name'] = name.lower()

        cls = super().__new__(mcls, name, bases, members)

        mcls.registry[formatter_name] = cls

        return cls


class Base(metaclass=_FormatterMeta):
    """
    The abstract base class of all unit formats.
    """

    def __new__(cls, *args, **kwargs):
        # This __new__ is to make it clear that there is no reason to
        # instantiate a Formatter--if you try to you'll just get back the
        # class
        return cls

    @classmethod
    def parse(cls, s):
        """
        Convert a string to a unit object.
        """

        raise NotImplementedError(
            f"Can not parse with {cls.__name__} format")

    @classmethod
    def to_string(cls, u):
        """
        Convert a unit object to a string.
        """

        raise NotImplementedError(
            f"Can not output in {cls.__name__} format")

## Instruction:
Remove use of metaclass for unit formats
## Code After:

class Base:
    """
    The abstract base class of all unit formats.
    """
    registry = {}

    def __new__(cls, *args, **kwargs):
        # This __new__ is to make it clear that there is no reason to
        # instantiate a Formatter--if you try to you'll just get back the
        # class
        return cls

    def __init_subclass__(cls, **kwargs):
        # Keep a registry of all formats.  Key by the class name unless a name
        # is explicitly set (i.e., one *not* inherited from a superclass).
        if 'name' not in cls.__dict__:
            cls.name = cls.__name__.lower()

        Base.registry[cls.name] = cls
        super().__init_subclass__(**kwargs)

    @classmethod
    def parse(cls, s):
        """
        Convert a string to a unit object.
        """

        raise NotImplementedError(
            f"Can not parse with {cls.__name__} format")

    @classmethod
    def to_string(cls, u):
        """
        Convert a unit object to a string.
        """

        raise NotImplementedError(
            f"Can not output in {cls.__name__} format")
