@@ -14,6 +14,8 @@ from typing import (
14
14
Iterator ,
15
15
)
16
16
17
+ from typing_extensions import Literal
18
+
17
19
_K = TypeVar ("_K" )
18
20
_V = TypeVar ("_V" )
19
21
@@ -27,24 +29,22 @@ class OrderedSet(MutableSet[_K]):
27
29
28
30
class MultiValueDictKeyError (KeyError ): ...
29
31
30
- _Val = Union [_V , List [_V ]]
31
-
32
32
class MultiValueDict (MutableMapping [_K , _V ]):
33
33
@overload
34
- def __init__ (self , key_to_list_mapping : Iterable [Tuple [_K , _Val ]] = ...) -> None : ...
34
+ def __init__ (self , key_to_list_mapping : Iterable [Tuple [_K , Union [ _V , List [ _V ]] ]] = ...) -> None : ...
35
35
@overload
36
- def __init__ (self , key_to_list_mapping : Mapping [_K , _Val ] = ...) -> None : ...
36
+ def __init__ (self , key_to_list_mapping : Mapping [_K , Union [ _V , List [ _V ]] ] = ...) -> None : ...
37
37
def getlist (self , key : _K , default : List [_V ] = None ) -> List [_V ]: ...
38
38
def setlist (self , key : _K , list_ : List [_V ]) -> None : ...
39
39
def setlistdefault (self , key : _K , default_list : List [_V ] = None ) -> List [_V ]: ...
40
40
def appendlist (self , key : _K , value : _V ) -> None : ...
41
41
def lists (self ) -> Iterable [Tuple [_K , List [_V ]]]: ...
42
- def dict (self ) -> Dict [_K , _Val ]: ...
42
+ def dict (self ) -> Dict [_K , Union [ _V , List [ _V ]] ]: ...
43
43
def copy (self ) -> MultiValueDict [_K , _V ]: ...
44
44
# These overrides are needed to convince mypy that this isn't an abstract class
45
45
def __delitem__ (self , item : _K ) -> None : ...
46
- def __getitem__ (self , item : _K ) -> _Val : ... # type: ignore
47
- def __setitem__ (self , k : _K , v : _Val ) -> None : ...
46
+ def __getitem__ (self , item : _K ) -> Union [ _V , Literal [[]]] : ... # type: ignore
47
+ def __setitem__ (self , k : _K , v : Union [ _V , List [ _V ]] ) -> None : ...
48
48
def __len__ (self ) -> int : ...
49
49
def __iter__ (self ) -> Iterator [_K ]: ...
50
50
0 commit comments