@@ -679,7 +679,7 @@ def _callable_type_to_method(name, typ, ctx):
679679 return head (func )
680680
681681
682- def _function_type_from_sig (sig , func , * , receiver_type ):
682+ def _function_type_from_sig (sig , func_type , * , receiver_type ):
683683 empty = inspect .Parameter .empty
684684
685685 def _ann (x ):
@@ -691,12 +691,12 @@ def _ann(x):
691691 for i , p in enumerate (sig .parameters .values ()):
692692 ann = p .annotation
693693 # Special handling for first argument on methods.
694- if i == 0 and receiver_type and not isinstance ( func , staticmethod ) :
694+ if i == 0 and receiver_type and func_type is not staticmethod :
695695 if ann is empty :
696696 ann = receiver_type
697697 else :
698698 if (
699- isinstance ( func , classmethod )
699+ func_type is classmethod
700700 and typing .get_origin (ann ) is type
701701 and (receiver_args := typing .get_args (ann ))
702702 ):
@@ -729,9 +729,9 @@ def _ann(x):
729729 # TODO: Is doing the tuple for staticmethod/classmethod legit?
730730 # Putting a list in makes it unhashable...
731731 f : typing .Any # type: ignore[annotation-unchecked]
732- if isinstance ( func , staticmethod ) :
732+ if func_type is staticmethod :
733733 f = staticmethod [tuple [* params ], ret ]
734- elif isinstance ( func , classmethod ) :
734+ elif func_type is classmethod :
735735 f = classmethod [specified_receiver , tuple [* params [1 :]], ret ]
736736 else :
737737 f = typing .Callable [params , ret ]
@@ -744,7 +744,7 @@ def _function_type(
744744) -> type [typing .Callable | classmethod | staticmethod | GenericCallable ]:
745745 root = inspect .unwrap (func )
746746 sig = inspect .signature (root )
747- f = _function_type_from_sig (sig , func , receiver_type = receiver_type )
747+ f = _function_type_from_sig (sig , type ( func ) , receiver_type = receiver_type )
748748
749749 if root .__type_params__ :
750750 # Must store a lambda that performs type variable substitution
0 commit comments