code: def test_varargs(self):
      @typecheck(x=int, y=int)
      def f1(x, y):
          return x + y
  
      # ensure that f1 and f2 both run with correct arguments
      f1(1, 2)
  
      self.assertRaises(TypeError, lambda: f1("2", 3))
  
      @typecheck(x=int, y=int)
      def bad_signature_1(x, y, *args):
          pass
  
      @typecheck(x=int, y=int)
      def bad_signature_2(x, y, **kwargs):
          pass
  
      @typecheck(x=int)
      def bad_signature_3(x, *args, **kwargs):
          pass
  
      for f in [bad_signature_1, bad_signature_2, bad_signature_3]:
          self.assertRaises(RuntimeError, lambda: f(1, 2))
  
      @typecheck()
      def f():
          pass
  
      f()
  
      @typecheck(x=int, y=int, args=int)
      def good_signature_1(x, y, *args):
          pass
  
      good_signature_1(1, 2)
      good_signature_1(1, 2, 3)
      good_signature_1(1, 2, 3, 4, 5)
  
      self.assertRaises(
          TypeError, lambda: good_signature_1(1, 2, 3, "4")
      )
      self.assertRaises(TypeError, lambda: good_signature_1(1, 2, "4"))
  
      @typecheck(x=int, y=int, kwargs=int)
      def good_signature_2(x, y, **kwargs):
          pass
  
      good_signature_2(1, 2, a=5, z=2)
      good_signature_2(1, 2)
      good_signature_2(1, 2, a=5)
  
      self.assertRaises(
          TypeError, lambda: good_signature_2(1, 2, a="2")
      )
      self.assertRaises(
          TypeError, lambda: good_signature_2(1, 2, a="2", b=5, c=10)
      )
  
      @typecheck(x=int, y=int, args=int, kwargs=int)
      def good_signature_3(x, y, *args, **kwargs):
          pass
  
      good_signature_3(1, 2)
      good_signature_3(1, 2, 3)
      good_signature_3(1, 2, a=3)
      good_signature_3(1, 2, 3, a=4)
  
      self.assertRaises(
          TypeError, lambda: good_signature_3(1, 2, a="2")
      )
      self.assertRaises(
          TypeError, lambda: good_signature_3(1, 2, "3", b=5, c=10)
      )
      self.assertRaises(
          TypeError, lambda: good_signature_3(1, 2, "3", b="5", c=10)
      )
  
      @typecheck(
          x=int, y=int, args=int, kwargs=oneof(sequenceof(int), str)
      )
      def good_signature_4(x, y, *args, **kwargs):
          pass
  
      good_signature_4(1, 2)
      good_signature_4(1, 2, 3)
      good_signature_4(1, 2, a="1")
      good_signature_4(1, 2, 3, a=[1, 2, 3])
      good_signature_4(1, 2, 3, a=[1, 2, 3], b="5")
      good_signature_4(1, 2, a=[1, 2, 3], b="5")
  
      self.assertRaises(TypeError, lambda: good_signature_4(1, 2, a=2))
      self.assertRaises(
          TypeError, lambda: good_signature_4(1, 2, "3", b="5", c=10)
      )
  
      @typecheck(x=sized_tupleof(str, int, int))
      def good_signature_5(x):
          pass
  
      good_signature_5(("1", 5, 10))
      self.assertRaises(TypeError, lambda: good_signature_5("1", 2, 2))
      self.assertRaises(
          TypeError,
          lambda: good_signature_5(("1", 5, 10), ("2", 10, 20)),
      )
  
      @typecheck(
          x=int,
          y=str,
          z=sequenceof(sized_tupleof(str, int, int)),
          args=int,
      )
      def good_signature_6(x, y, z, *args):
          pass
  
      good_signature_6(
          7, "hello", [("1", 5, 10), ("3", 10, 1)], 1, 2, 3
      )
      good_signature_6(7, "hello", [("1", 5, 10), ("3", 10, 1)])
      good_signature_6(7, "hello", [], 1, 2)
      good_signature_6(7, "hello", [])
      self.assertRaises(
          TypeError, lambda: good_signature_6(1, "2", ("3", 4, 5))
      )
      self.assertRaises(
          TypeError,
          lambda: good_signature_6(
              7, "hello", [(9, 5.6, 10), (4, "hello", 1)], 1, 2, 3
          ),
      )
  
file_path: hail/hail/python/test/hail/typecheck/test_typecheck.py
imports: import unittest
  from hail.typecheck.check import *
label_desc: Use image node_id 1 for calling the Tests obj's underlying member method code with example usage: obj.test_varargs() and returns: unknown