示例#1
0
 def _param_count_of_type(self, type_: Optional[Type]) -> int:
     """
     Return the number of parameters that have the specified type.
     :param type_: The type, whose occurrences should be counted.
     :return: The number of occurrences.
     """
     count = 0
     if not type_:
         return 0
     for var_ref in self.args:
         if is_assignable_to(var_ref.variable_type, type_):
             count += 1
     for _, var_ref in self.kwargs.items():
         if is_assignable_to(var_ref.variable_type, type_):
             count += 1
     return count
示例#2
0
def test_is_assignable_to(from_type, to_type, result):
    assert is_assignable_to(from_type, to_type) == result