File tree Expand file tree Collapse file tree 2 files changed +19
-16
lines changed Expand file tree Collapse file tree 2 files changed +19
-16
lines changed Original file line number Diff line number Diff line change 55""" 
66
77
8- def  make_object (cls ):
9-     return  cls ()
8+ def  make_object (cls ): ...
109
1110
1211## End of your code ## 
12+ from  typing  import  assert_type 
13+ 
14+ 
1315class  MyClass :
1416    pass 
1517
@@ -18,8 +20,9 @@ def f():
1820    pass 
1921
2022
21- c  =  make_object (MyClass )
22- c  =  make_object (int )
23- c  =  make_object (f )  # expect-type-error 
24- c  =  make_object ("sss" )  # expect-type-error 
25- c  =  make_object (["sss" ])  # expect-type-error 
23+ assert_type (make_object (MyClass ), MyClass )
24+ assert_type (make_object (int ), int )
25+ 
26+ make_object (f )  # expect-type-error 
27+ make_object ("sss" )  # expect-type-error 
28+ make_object (["sss" ])  # expect-type-error 
Original file line number Diff line number Diff line change 44`make_object` takes a class returns an instance of it. 
55""" 
66
7- from   typing   import   Any 
7+ def   make_object [ T ]( cls :  type [ T ])  ->   T : ... 
88
99
10- def   make_object ( cls :  type [ Any ]): 
11-      return   cls () 
10+ ## End of your code ## 
11+ from   typing   import   assert_type 
1212
1313
14- ## End of your code ## 
1514class  MyClass :
1615    pass 
1716
@@ -20,8 +19,9 @@ def f():
2019    pass 
2120
2221
23- c  =  make_object (MyClass )
24- c  =  make_object (int )
25- c  =  make_object (f )  # expect-type-error 
26- c  =  make_object ("sss" )  # expect-type-error 
27- c  =  make_object (["sss" ])  # expect-type-error 
22+ assert_type (make_object (MyClass ), MyClass )
23+ assert_type (make_object (int ), int )
24+ 
25+ make_object (f )  # expect-type-error 
26+ make_object ("sss" )  # expect-type-error 
27+ make_object (["sss" ])  # expect-type-error 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments