code: def final(arg):
      
      if inspect.isclass(arg):
          if not isinstance(arg, ObjectMetaclass):
              raise ValueError("@final can only be applied to a class "
                               "that is a subclass of Object")
      elif not is_method(arg):
          raise TypeError("@final can only be applied to classes or methods")
  
      method = arg.method if isinstance(arg, _WrappedMethod) else arg
      method.__final__ = True
  
      return arg
docs: Mark a class or method as _final_.
  
      Final classes are those that end the inheritance chain, i.e. forbid
      further subclassing. A final class can thus be only instantiated,
      not inherited from.
  
      Similarly, methods marked as final in a superclass cannot be overridden
      in any of the subclasses.
  
      .. note::
  
          Final method itself can also be (in fact, it usually is) an overridden
          method from a superclass. In those cases, it's recommended to place
          @\ :func:`final` modifier before @\ :func:`override` for clarity::
  
              class Foo(Base):
                  @final
                  @override
                  def florb(self):
                      super(Foo, self).florb()
                      # ...
  
      .. versionadded:: 0.0.3
         Now applicable to methods in addition to classes