Skip to content

Commit

Permalink
Mark some types as non-hashable (#3219)
Browse files Browse the repository at this point in the history
Based on @JelleZijlstra's PR #2221.

Fixes #2148
  • Loading branch information
srittau committed Sep 4, 2019
1 parent 1d21315 commit efb4af0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
7 changes: 5 additions & 2 deletions stdlib/2/__builtin__.pyi
Expand Up @@ -734,7 +734,7 @@ class bytearray(MutableSequence[int], ByteString):
def __repr__(self) -> str: ...
def __int__(self) -> int: ...
def __float__(self) -> float: ...
def __hash__(self) -> int: ...
__hash__: None # type: ignore
@overload
def __getitem__(self, i: int) -> int: ...
@overload
Expand Down Expand Up @@ -849,6 +849,7 @@ class slice(object):
def __init__(self, stop: Any) -> None: ...
@overload
def __init__(self, start: Any, stop: Any, step: Any = ...) -> None: ...
__hash__: None # type: ignore
def indices(self, len: int) -> Tuple[int, int, int]: ...

class tuple(Sequence[_T_co], Generic[_T_co]):
Expand Down Expand Up @@ -906,7 +907,7 @@ class list(MutableSequence[_T], Generic[_T]):
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[_T]: ...
def __str__(self) -> str: ...
def __hash__(self) -> int: ...
__hash__: None # type: ignore
@overload
def __getitem__(self, i: int) -> _T: ...
@overload
Expand Down Expand Up @@ -980,6 +981,7 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
def __delitem__(self, v: _KT) -> None: ...
def __iter__(self) -> Iterator[_KT]: ...
def __str__(self) -> str: ...
__hash__: None # type: ignore

class set(MutableSet[_T], Generic[_T]):
def __init__(self, iterable: Iterable[_T] = ...) -> None: ...
Expand Down Expand Up @@ -1016,6 +1018,7 @@ class set(MutableSet[_T], Generic[_T]):
def __lt__(self, s: AbstractSet[object]) -> bool: ...
def __ge__(self, s: AbstractSet[object]) -> bool: ...
def __gt__(self, s: AbstractSet[object]) -> bool: ...
__hash__: None # type: ignore

class frozenset(AbstractSet[_T], Generic[_T]):
def __init__(self, iterable: Iterable[_T] = ...) -> None: ...
Expand Down
7 changes: 5 additions & 2 deletions stdlib/2and3/builtins.pyi
Expand Up @@ -734,7 +734,7 @@ class bytearray(MutableSequence[int], ByteString):
def __repr__(self) -> str: ...
def __int__(self) -> int: ...
def __float__(self) -> float: ...
def __hash__(self) -> int: ...
__hash__: None # type: ignore
@overload
def __getitem__(self, i: int) -> int: ...
@overload
Expand Down Expand Up @@ -849,6 +849,7 @@ class slice(object):
def __init__(self, stop: Any) -> None: ...
@overload
def __init__(self, start: Any, stop: Any, step: Any = ...) -> None: ...
__hash__: None # type: ignore
def indices(self, len: int) -> Tuple[int, int, int]: ...

class tuple(Sequence[_T_co], Generic[_T_co]):
Expand Down Expand Up @@ -906,7 +907,7 @@ class list(MutableSequence[_T], Generic[_T]):
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[_T]: ...
def __str__(self) -> str: ...
def __hash__(self) -> int: ...
__hash__: None # type: ignore
@overload
def __getitem__(self, i: int) -> _T: ...
@overload
Expand Down Expand Up @@ -980,6 +981,7 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
def __delitem__(self, v: _KT) -> None: ...
def __iter__(self) -> Iterator[_KT]: ...
def __str__(self) -> str: ...
__hash__: None # type: ignore

class set(MutableSet[_T], Generic[_T]):
def __init__(self, iterable: Iterable[_T] = ...) -> None: ...
Expand Down Expand Up @@ -1016,6 +1018,7 @@ class set(MutableSet[_T], Generic[_T]):
def __lt__(self, s: AbstractSet[object]) -> bool: ...
def __ge__(self, s: AbstractSet[object]) -> bool: ...
def __gt__(self, s: AbstractSet[object]) -> bool: ...
__hash__: None # type: ignore

class frozenset(AbstractSet[_T], Generic[_T]):
def __init__(self, iterable: Iterable[_T] = ...) -> None: ...
Expand Down
24 changes: 12 additions & 12 deletions third_party/2and3/werkzeug/datastructures.pyi
Expand Up @@ -11,8 +11,8 @@ def is_immutable(self): ...
def iter_multi_items(mapping): ...
def native_itermethods(names): ...

class ImmutableListMixin:
def __hash__(self): ...
class ImmutableListMixin(object):
def __hash__(self) -> int: ...
def __reduce_ex__(self, protocol): ...
def __delitem__(self, key): ...
def __delslice__(self, i, j): ...
Expand All @@ -28,13 +28,13 @@ class ImmutableListMixin:
def reverse(self): ...
def sort(self, cmp: Optional[Any] = ..., key: Optional[Any] = ..., reverse: Optional[Any] = ...): ...

class ImmutableList(ImmutableListMixin, list): ...
class ImmutableList(ImmutableListMixin, list): ... # type: ignore

class ImmutableDictMixin:
class ImmutableDictMixin(object):
@classmethod
def fromkeys(cls, *args, **kwargs): ...
def __reduce_ex__(self, protocol): ...
def __hash__(self): ...
def __hash__(self) -> int: ...
def setdefault(self, key, default: Optional[Any] = ...): ...
def update(self, *args, **kwargs): ...
def pop(self, key, default: Optional[Any] = ...): ...
Expand Down Expand Up @@ -71,7 +71,7 @@ class TypeConversionDict(Dict[_K, _V]):
@overload
def get(self, key: _K, default: _D, type: Callable[[_V], _R]) -> Union[_R, _D]: ...

class ImmutableTypeConversionDict(ImmutableDictMixin, TypeConversionDict[_K, _V]):
class ImmutableTypeConversionDict(ImmutableDictMixin, TypeConversionDict[_K, _V]): # type: ignore
def copy(self) -> TypeConversionDict[_K, _V]: ...
def __copy__(self) -> ImmutableTypeConversionDict[_K, _V]: ...

Expand Down Expand Up @@ -207,7 +207,7 @@ class EnvironHeaders(ImmutableHeadersMixin, Headers):
def __iter__(self): ...
def copy(self): ...

class CombinedMultiDict(ImmutableMultiDictMixin, MultiDict):
class CombinedMultiDict(ImmutableMultiDictMixin, MultiDict): # type: ignore
def __reduce_ex__(self, protocol): ...
dicts: Any
def __init__(self, dicts: Optional[Any] = ...): ...
Expand All @@ -231,15 +231,15 @@ class CombinedMultiDict(ImmutableMultiDictMixin, MultiDict):
class FileMultiDict(MultiDict):
def add_file(self, name, file, filename: Optional[Any] = ..., content_type: Optional[Any] = ...): ...

class ImmutableDict(ImmutableDictMixin, dict):
class ImmutableDict(ImmutableDictMixin, dict): # type: ignore
def copy(self): ...
def __copy__(self): ...

class ImmutableMultiDict(ImmutableMultiDictMixin, MultiDict):
class ImmutableMultiDict(ImmutableMultiDictMixin, MultiDict): # type: ignore
def copy(self): ...
def __copy__(self): ...

class ImmutableOrderedMultiDict(ImmutableMultiDictMixin, OrderedMultiDict):
class ImmutableOrderedMultiDict(ImmutableMultiDictMixin, OrderedMultiDict): # type: ignore
def copy(self): ...
def __copy__(self): ...

Expand Down Expand Up @@ -280,7 +280,7 @@ class _CacheControl(UpdateDictMixin, dict):
def __init__(self, values=..., on_update: Optional[Any] = ...): ...
def to_header(self): ...

class RequestCacheControl(ImmutableDictMixin, _CacheControl):
class RequestCacheControl(ImmutableDictMixin, _CacheControl): # type: ignore
max_stale: Any
min_fresh: Any
no_transform: Any
Expand Down Expand Up @@ -360,7 +360,7 @@ class ContentRange:
def __nonzero__(self): ...
__bool__: Any

class Authorization(ImmutableDictMixin, Dict[str, Any]):
class Authorization(ImmutableDictMixin, Dict[str, Any]): # type: ignore
type: str
def __init__(self, auth_type: str, data: Optional[Mapping[str, Any]] = ...) -> None: ...
@property
Expand Down

0 comments on commit efb4af0

Please sign in to comment.