From 26dfcb6859950e069ef7fd6b79e9a214bf71971a Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Fri, 14 Oct 2016 09:41:26 -0700 Subject: [PATCH] Make dict.fromkeys() a classmethod (which it is). (#604) This came up in https://github.com/python/mypy/issues/2254. I don't know why it was previously defined as a staticmethod, perhaps there was an old mypy issue? --- stdlib/2.7/__builtin__.pyi | 8 ++++---- stdlib/3/builtins.pyi | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/stdlib/2.7/__builtin__.pyi b/stdlib/2.7/__builtin__.pyi index 9e3dd3332..049e61aa8 100644 --- a/stdlib/2.7/__builtin__.pyi +++ b/stdlib/2.7/__builtin__.pyi @@ -550,12 +550,12 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]): def viewkeys(self) -> KeysView[_KT]: ... def viewvalues(self) -> ValuesView[_VT]: ... def viewitems(self) -> ItemsView[_KT, _VT]: ... - @staticmethod @overload - def fromkeys(seq: Sequence[_T]) -> Dict[_T, Any]: ... # TODO: Actually a class method - @staticmethod + @classmethod + def fromkeys(cls, seq: Sequence[_T]) -> Dict[_T, Any]: ... @overload - def fromkeys(seq: Sequence[_T], value: _S) -> Dict[_T, _S]: ... + @classmethod + def fromkeys(cls, seq: Sequence[_T], value: _S) -> Dict[_T, _S]: ... def __len__(self) -> int: ... def __getitem__(self, k: _KT) -> _VT: ... def __setitem__(self, k: _KT, v: _VT) -> None: ... diff --git a/stdlib/3/builtins.pyi b/stdlib/3/builtins.pyi index 73c7cdf03..036b9b401 100644 --- a/stdlib/3/builtins.pyi +++ b/stdlib/3/builtins.pyi @@ -529,12 +529,12 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]): def keys(self) -> KeysView[_KT]: ... def values(self) -> ValuesView[_VT]: ... def items(self) -> ItemsView[_KT, _VT]: ... - @staticmethod @overload - def fromkeys(seq: Sequence[_T]) -> Dict[_T, Any]: ... # TODO: Actually a class method - @staticmethod + @classmethod + def fromkeys(cls, seq: Sequence[_T]) -> Dict[_T, Any]: ... @overload - def fromkeys(seq: Sequence[_T], value: _S) -> Dict[_T, _S]: ... + @classmethod + def fromkeys(cls, seq: Sequence[_T], value: _S) -> Dict[_T, _S]: ... def __len__(self) -> int: ... def __getitem__(self, k: _KT) -> _VT: ... def __setitem__(self, k: _KT, v: _VT) -> None: ...