File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -10772,6 +10772,20 @@ def func_packed(arg1: int, arg2: str) -> bool:
1077210772    def  test_hashable (self ):
1077310773        self .assertEqual (hash (typing ._UnionGenericAlias ), hash (Union ))
1077410774
10775+ class  TestCallableAlias (BaseTestCase ):
10776+     def  test_callable_alias_preserves_subclass (self ):
10777+         C  =  Callable [[str , ForwardRef ("int" )], int ]
10778+         class  A :
10779+             c : C 
10780+         
10781+         hints  =  get_type_hints (A )
10782+ 
10783+         # Ensure evaluated type retains the correct class 
10784+         self .assertEqual (hints ['c' ].__class__ , C .__class__ )
10785+ 
10786+         # Instead of comparing raw ForwardRef, check if the resolution is correct 
10787+         expected_args  =  tuple (int  if  isinstance (arg , ForwardRef ) else  arg  for  arg  in  C .__args__ )
10788+         self .assertEqual (hints ['c' ].__args__ , expected_args )
1077510789
1077610790def  load_tests (loader , tests , pattern ):
1077710791    import  doctest 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments