From b46b66c187bc6248de5815e4231e168421a099b8 Mon Sep 17 00:00:00 2001 From: Greg Price Date: Thu, 17 Dec 2015 14:49:34 -0800 Subject: [PATCH 1/2] Share `operator` in 2and3 --- builtins/{2.7 => 2and3}/operator.pyi | 0 builtins/3/operator.pyi | 7 ------- 2 files changed, 7 deletions(-) rename builtins/{2.7 => 2and3}/operator.pyi (100%) delete mode 100644 builtins/3/operator.pyi diff --git a/builtins/2.7/operator.pyi b/builtins/2and3/operator.pyi similarity index 100% rename from builtins/2.7/operator.pyi rename to builtins/2and3/operator.pyi diff --git a/builtins/3/operator.pyi b/builtins/3/operator.pyi deleted file mode 100644 index 7785fbe6e..000000000 --- a/builtins/3/operator.pyi +++ /dev/null @@ -1,7 +0,0 @@ -# Stubs for operator - -# NOTE: These are incomplete! - -from typing import Any - -def add(a: Any, b: Any) -> Any: ... From 667b98040aa3c23053a9c54bc80520c9858959e2 Mon Sep 17 00:00:00 2001 From: Greg Price Date: Thu, 17 Dec 2015 15:12:47 -0800 Subject: [PATCH 2/2] 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]: ...