File tree 9 files changed +68
-1
lines changed
9 files changed +68
-1
lines changed Original file line number Diff line number Diff line change
1
+ from typing import Any
2
+
3
+
4
+ def foo (x : Any ):
5
+ pass
6
+
7
+
8
+ ## End of your code ##
9
+ foo (1 )
10
+ foo ("10" )
11
+ foo (1 , 2 ) # expect-type-error
Original file line number Diff line number Diff line change
1
+ def foo (x : dict [str , str ]):
2
+ pass
3
+
4
+
5
+ ## End of your code ##
6
+ foo ({"foo" : "bar" })
7
+ foo ({"foo" : 1 }) # expect-type-error
Original file line number Diff line number Diff line change
1
+ def foo (x : list [str ]):
2
+ pass
3
+
4
+
5
+ ## End of your code ##
6
+ foo (["foo" , "bar" ])
7
+ foo (["foo" , 1 ]) # expect-type-error
Original file line number Diff line number Diff line change
1
+ def foo (x : int | None = 0 ):
2
+ pass
3
+
4
+
5
+ ## End of your code ##
6
+ foo (10 )
7
+ foo ()
8
+
9
+ foo ("10" ) # expect-type-error
Original file line number Diff line number Diff line change
1
+ def foo (x : int ):
2
+ pass
3
+
4
+
5
+ ## End of your code ##
6
+ foo (10 )
7
+
8
+ foo ("10" ) # expect-type-error
Original file line number Diff line number Diff line change
1
+ def foo () -> int :
2
+ return 1
3
+
4
+
5
+ ## End of your code ##
6
+ from typing import assert_type
7
+
8
+ assert_type (foo (), int )
9
+ assert_type (foo (), str ) # expect-type-error
Original file line number Diff line number Diff line change
1
+ def foo (x : tuple [str , int ]):
2
+ pass
3
+
4
+
5
+ ## End of your code ##
6
+ foo (("foo" , 1 ))
7
+
8
+ foo ((1 , 2 )) # expect-type-error
9
+ foo (("foo" , "bar" )) # expect-type-error
10
+ foo ((1 , "foo" )) # expect-type-error
Original file line number Diff line number Diff line change
1
+ a : int
2
+
3
+
4
+ ## End of your code ##
5
+ a = 2
6
+ a = "1" # expect-type-erro
Original file line number Diff line number Diff line change 2
2
TODO:
3
3
4
4
Define a callable type that accepts a string parameter and returns None.
5
- *The parameter name can be any .*
5
+ *The parameter name can be arbitrary .*
6
6
"""
7
7
8
8
SingleStringInput = ...
You can’t perform that action at this time.
0 commit comments