88
99def test_primitive ():
1010 """Test primitive types"""
11- assert guess_type (int ) == "integer "
11+ assert guess_type (int ) == "number "
1212 assert guess_type (str ) == "string"
1313 assert guess_type (float ) == "number"
1414 assert guess_type (bool ) == "boolean"
@@ -32,39 +32,39 @@ def test_typings():
3232
3333def test_optional ():
3434 """Test optional types"""
35- assert guess_type (typing .Optional [int ]) == "integer "
35+ assert guess_type (typing .Optional [int ]) == "number "
3636 assert guess_type (typing .Optional [str ]) == "string"
3737 assert guess_type (typing .Optional [float ]) == "number"
3838 assert guess_type (typing .Optional [bool ]) == "boolean"
3939
4040
4141def test_union_null ():
4242 """Test union types with null"""
43- assert guess_type (typing .Union [int , None ]) == "integer "
43+ assert guess_type (typing .Union [int , None ]) == "number "
4444 assert guess_type (typing .Union [str , None ]) == "string"
4545 assert guess_type (typing .Union [float , None ]) == "number"
4646 assert guess_type (typing .Union [bool , None ]) == "boolean"
4747
4848
4949def test_union ():
5050 """Test union types"""
51- assert guess_type (typing .Union [int , str ]) == [ "integer " , "string" ]
51+ assert set ( guess_type (typing .Union [int , str ])) == { "number " , "string" }
5252 assert guess_type (typing .Union [int , float ]) == "number"
53- assert guess_type (typing .Union [int , bool ]) == [ "integer " , "boolean" ]
54- assert guess_type (typing .Union [bool , int ]) == [ "boolean" , "integer" ]
55- assert guess_type (typing .Union [str , float ]) == [ "string" , "number" ]
56- assert guess_type (typing .Union [str , bool ]) == [ "string" , "boolean" ]
57- assert guess_type (typing .Union [float , bool ]) == [ "number" , "boolean" ]
58- assert guess_type (typing .Union [str , float , bool ]) == [
53+ assert set ( guess_type (typing .Union [int , bool ])) == { "number " , "boolean" }
54+ assert set ( guess_type (typing .Union [bool , int ])) == { "boolean" , "number" }
55+ assert set ( guess_type (typing .Union [str , float ])) == { "string" , "number" }
56+ assert set ( guess_type (typing .Union [str , bool ])) == { "string" , "boolean" }
57+ assert set ( guess_type (typing .Union [float , bool ])) == { "number" , "boolean" }
58+ assert set ( guess_type (typing .Union [str , float , bool ])) == {
5959 "string" ,
6060 "number" ,
6161 "boolean" ,
62- ]
63- assert guess_type (typing .Union [str , float , bool , None ]) == [
62+ }
63+ assert set ( guess_type (typing .Union [str , float , bool , None ])) == {
6464 "string" ,
6565 "number" ,
6666 "boolean" ,
67- ]
67+ }
6868
6969
7070current_version = packaging .version .parse (platform .python_version ())
@@ -77,37 +77,36 @@ def test_union():
7777def test_union_type ():
7878 """Test union types in Python 3.10+"""
7979
80- assert guess_type (int | str ) == [ "integer " , "string" ]
80+ assert set ( guess_type (int | str )) == { "number " , "string" }
8181 assert guess_type (int | float ) == "number"
82- assert guess_type (int | bool ) == ["integer" , "boolean" ]
83- assert guess_type (bool | int ) == ["boolean" , "integer" ]
84- assert guess_type (str | float ) == ["string" , "number" ]
85- assert guess_type (str | bool ) == ["string" , "boolean" ]
86- assert guess_type (float | bool ) == ["number" , "boolean" ]
87- assert guess_type (str | float | bool ) == [
82+ assert set (guess_type (int | bool )) == {"number" , "boolean" }
83+ assert set (guess_type (str | float )) == {"string" , "number" }
84+ assert set (guess_type (str | bool )) == {"string" , "boolean" }
85+ assert set (guess_type (float | bool )) == {"number" , "boolean" }
86+ assert set (guess_type (str | float | bool )) == {
8887 "string" ,
8988 "number" ,
9089 "boolean" ,
91- ]
92- assert guess_type (str | float | bool | None ) == [
90+ }
91+ assert set ( guess_type (str | float | bool | None )) == {
9392 "string" ,
9493 "number" ,
9594 "boolean" ,
96- ]
95+ }
9796
9897
9998def test_literal_type ():
10099 """Test literal type"""
101100 assert guess_type (typing .Literal ["a" ]) == "string" , "should be string"
102- assert guess_type (typing .Literal [1 ]) == "integer " , "should be integer "
101+ assert guess_type (typing .Literal [1 ]) == "number " , "should be number "
103102 assert guess_type (typing .Literal [1.0 ]) == "number" , "should be number"
104103
105104 assert set (guess_type (typing .Literal ["a" , 1 , None ])) == {
106105 "string" ,
107- "integer " ,
106+ "number " ,
108107 }, "should be string or integer, omit None"
109108
110- assert set (guess_type (typing .Literal ["a" , 1 ])) == {"string" , "integer " }
109+ assert set (guess_type (typing .Literal ["a" , 1 ])) == {"string" , "number " }
111110 assert set (guess_type (typing .Literal ["a" , 1.0 ])) == {"string" , "number" }
112111 assert set (guess_type (typing .Literal ["a" , 1.1 ])) == {"string" , "number" }
113112 assert set (guess_type (typing .Literal ["a" , 1 , 1.0 ])) == {
0 commit comments