title: Write a decorator for a Python dataclass
body: <p>I have the following dataclass:</p>
  <pre><code>@dataclass(frozen=True)
  class Info:
      client_id: str
      purchase_id: str
  </code></pre>
  <p>Both these ids are supposed to be UUID's.</p>
  <p>I have a method that can check if the arg is UUID:</p>
  <pre><code>from uuid import UUID 
  
  def check_uuid(arg):
      try:
          UUID(arg)
      except ValueError:
          raise argparse.ArgumentTypeError(f&quot;'{arg}' is not a valid UUID&quot;)
      return arg
  </code></pre>
  <p>I want to define a decorator that I can wrap around my dataclass to perform this check. Something like this:</p>
  <pre><code>@check_types
  @dataclass(frozen=True)
  class Info:
      client_id: str
      purchase_id: str
  </code></pre>
  <p>Here is what I wrote:</p>
  <pre><code>from functools import wraps
  
  import argparse
  import inspect
  
  
  def check_types(callable):
  
      def check_uuid(*args, **kwargs):
          for arg in args[1:]
              try:
                  UUID(arg)
              except ValueError:
                  raise argparse.ArgumentTypeError(f&quot;'{arg}' is not a valid UUID&quot;)
  
      def decorate(func):
          @wraps(func)
          def wrapper(*args, **kwargs):
              check_uuid(*args, **kwargs)
              return func(*args, **kwargs)
          return wrapper
  
      if inspect.isclass(callable):
          callable.__init__ = decorate(callable.__init__)
          return callable
  
      return decorate(callable)
  </code></pre>
  <p>but when I instantiate the class <code>i = Info(&quot;123e4567-e89b-12d3-a456-426614174000&quot;, &quot;123e4567-e89b-12d3-a456-426614174000&quot;)</code></p>
  <p>I get the following error:</p>
  <pre><code>TypeError: object.__init__() takes exactly one argument (the instance to initialize)
  </code></pre>
  <p>I am not sure what I am missing, alternatively, is there a better way I can be type checking for UUIDs when the class is instantiated?</p>