From 667b98040aa3c23053a9c54bc80520c9858959e2 Mon Sep 17 00:00:00 2001 From: Greg Price Date: Thu, 17 Dec 2015 15:12:47 -0800 Subject: [PATCH] operator: Make attrgetter, itemgetter, methodcaller usable --- builtins/2and3/operator.pyi | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/builtins/2and3/operator.pyi b/builtins/2and3/operator.pyi index 4f12ab197..ae5c4ba2d 100644 --- a/builtins/2and3/operator.pyi +++ b/builtins/2and3/operator.pyi @@ -1,6 +1,6 @@ # Stubs for operator -from typing import Any +from typing import Any, Callable def __abs__(a: Any) -> Any: ... def __add__(a: Any, b: Any) -> Any: ... @@ -114,11 +114,14 @@ def truediv(a: Any, b: Any) -> Any: ... def truth(x: Any) -> bool: ... def xor(a: Any, b: Any) -> Any: ... -class attrgetter(object): - def __init__(self, name: Any) -> None: ... +# Unsupported feature: "If more than one attribute is requested, +# returns a tuple of attributes." +# Unsupported: on Python 2 the parameter type should be `basestring`. +def attrgetter(attr: str) -> Callable[[Any], Any]: ... -class itemgetter(object): - def __init__(self, key: Any) -> None: ... +# Unsupported feature: "If multiple items are specified, returns a +# tuple of lookup values." +def itemgetter(item: Any) -> Callable[[Any], Any]: ... -class methodcaller(object): - def __init__(self, method_name: str, *args, **kwargs) -> None: ... +# Unsupported: on Python 2 the parameter type should be `basestring`. +def methodcaller(name: str, *args, **kwargs) -> Callable[[Any], Any]: ...