From 52b3c9028a57eb00e552900dc7905bed64d6df84 Mon Sep 17 00:00:00 2001 From: DeviousStoat Date: Sun, 21 Jul 2024 05:43:00 +0200 Subject: [PATCH] Type fixes --- src/pydash/chaining/all_funcs.pyi | 24 +++++++++++++++--------- src/pydash/objects.py | 26 +++++++++++++++++--------- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/src/pydash/chaining/all_funcs.pyi b/src/pydash/chaining/all_funcs.pyi index 11bf512..65f5238 100644 --- a/src/pydash/chaining/all_funcs.pyi +++ b/src/pydash/chaining/all_funcs.pyi @@ -2473,8 +2473,8 @@ class AllFuncs: @t.overload def invert(self: "Chain[t.Mapping[T, T2]]") -> "Chain[t.Dict[T2, T]]": ... @t.overload - def invert(self: "Chain[t.Iterable[T]]") -> "Chain[t.Dict[T, int]]": ... - def invert(self) -> "Chain[t.Dict]": + def invert(self: "Chain[t.Union[t.Iterator[T], t.Sequence[T]]]") -> "Chain[t.Dict[T, int]]": ... + def invert(self): return self._wrap(pyd.invert)() @t.overload @@ -2487,11 +2487,11 @@ class AllFuncs: ) -> "Chain[t.Dict[T2, t.List[T]]]": ... @t.overload def invert_by( - self: "Chain[t.Iterable[T]]", iteratee: t.Callable[[T], T2] + self: "Chain[t.Union[t.Iterator[T], t.Sequence[T]]]", iteratee: t.Callable[[T], T2] ) -> "Chain[t.Dict[T2, t.List[int]]]": ... @t.overload def invert_by( - self: "Chain[t.Iterable[T]]", iteratee: None = None + self: "Chain[t.Union[t.Iterator[T], t.Sequence[T]]]", iteratee: None = None ) -> "Chain[t.Dict[T, t.List[int]]]": ... def invert_by(self, iteratee=None): return self._wrap(pyd.invert_by)(iteratee) @@ -2622,7 +2622,9 @@ class AllFuncs: @t.overload def omit(self: "Chain[t.Mapping[T, T2]]", *properties: PathT) -> "Chain[t.Dict[T, T2]]": ... @t.overload - def omit(self: "Chain[t.Iterable[T]]", *properties: PathT) -> "Chain[t.Dict[int, T]]": ... + def omit( + self: "Chain[t.Union[t.Iterator[T], t.Sequence[T]]]", *properties: PathT + ) -> "Chain[t.Dict[int, T]]": ... @t.overload def omit(self: "Chain[t.Any]", *properties: PathT) -> "Chain[t.Dict]": ... def omit(self, *properties): @@ -2640,11 +2642,11 @@ class AllFuncs: def omit_by(self: "Chain[t.Dict[T, T2]]", iteratee: None = None) -> "Chain[t.Dict[T, T2]]": ... @t.overload def omit_by( - self: "Chain[t.Iterable[T]]", iteratee: t.Callable[[T, int], t.Any] + self: "Chain[t.Union[t.Iterator[T], t.Sequence[T]]]", iteratee: t.Callable[[T, int], t.Any] ) -> "Chain[t.Dict[int, T]]": ... @t.overload def omit_by( - self: "Chain[t.Iterable[T]]", iteratee: t.Callable[[T], t.Any] + self: "Chain[t.Union[t.Iterator[T], t.Sequence[T]]]", iteratee: t.Callable[[T], t.Any] ) -> "Chain[t.Dict[int, T]]": ... @t.overload def omit_by(self: "Chain[t.List[T]]", iteratee: None = None) -> "Chain[t.Dict[int, T]]": ... @@ -2725,7 +2727,9 @@ class AllFuncs: @t.overload def to_dict(self: "Chain[t.Mapping[T, T2]]") -> "Chain[t.Dict[T, T2]]": ... @t.overload - def to_dict(self: "Chain[t.Iterable[T]]") -> "Chain[t.Dict[int, T]]": ... + def to_dict( + self: "Chain[t.Union[t.Iterator[T], t.Sequence[T]]]", + ) -> "Chain[t.Dict[int, T]]": ... @t.overload def to_dict(self: "Chain[t.Any]") -> "Chain[t.Dict]": ... def to_dict(self): @@ -2751,7 +2755,9 @@ class AllFuncs: @t.overload def to_pairs(self: "Chain[t.Mapping[T, T2]]") -> "Chain[t.List[t.Tuple[T, T2]]]": ... @t.overload - def to_pairs(self: "Chain[t.Iterable[T]]") -> "Chain[t.List[t.Tuple[int, T]]]": ... + def to_pairs( + self: "Chain[t.Union[t.Iterator[T], t.Sequence[T]]]", + ) -> "Chain[t.List[t.Tuple[int, T]]]": ... @t.overload def to_pairs(self: "Chain[t.Any]") -> "Chain[t.List]": ... def to_pairs(self): diff --git a/src/pydash/objects.py b/src/pydash/objects.py index adca9dc..8220360 100644 --- a/src/pydash/objects.py +++ b/src/pydash/objects.py @@ -925,10 +925,10 @@ def invert(obj: t.Mapping[T, T2]) -> t.Dict[T2, T]: ... @t.overload -def invert(obj: t.Iterable[T]) -> t.Dict[T, int]: ... +def invert(obj: t.Union[t.Iterator[T], t.Sequence[T]]) -> t.Dict[T, int]: ... -def invert(obj) -> t.Dict: +def invert(obj): """ Creates an object composed of the inverted keys and values of the given object. @@ -967,11 +967,15 @@ def invert_by(obj: t.Mapping[T, T2], iteratee: None = None) -> t.Dict[T2, t.List @t.overload -def invert_by(obj: t.Iterable[T], iteratee: t.Callable[[T], T2]) -> t.Dict[T2, t.List[int]]: ... +def invert_by( + obj: t.Union[t.Iterator[T], t.Sequence[T]], iteratee: t.Callable[[T], T2] +) -> t.Dict[T2, t.List[int]]: ... @t.overload -def invert_by(obj: t.Iterable[T], iteratee: None = None) -> t.Dict[T, t.List[int]]: ... +def invert_by( + obj: t.Union[t.Iterator[T], t.Sequence[T]], iteratee: None = None +) -> t.Dict[T, t.List[int]]: ... def invert_by(obj, iteratee=None): @@ -1510,7 +1514,7 @@ def omit(obj: t.Mapping[T, T2], *properties: PathT) -> t.Dict[T, T2]: ... @t.overload -def omit(obj: t.Iterable[T], *properties: PathT) -> t.Dict[int, T]: ... +def omit(obj: t.Union[t.Iterator[T], t.Sequence[T]], *properties: PathT) -> t.Dict[int, T]: ... @t.overload @@ -1564,11 +1568,15 @@ def omit_by(obj: t.Dict[T, T2], iteratee: None = None) -> t.Dict[T, T2]: ... @t.overload -def omit_by(obj: t.Iterable[T], iteratee: t.Callable[[T, int], t.Any]) -> t.Dict[int, T]: ... +def omit_by( + obj: t.Union[t.Iterator[T], t.Sequence[T]], iteratee: t.Callable[[T, int], t.Any] +) -> t.Dict[int, T]: ... @t.overload -def omit_by(obj: t.Iterable[T], iteratee: t.Callable[[T], t.Any]) -> t.Dict[int, T]: ... +def omit_by( + obj: t.Union[t.Iterator[T], t.Sequence[T]], iteratee: t.Callable[[T], t.Any] +) -> t.Dict[int, T]: ... @t.overload @@ -1949,7 +1957,7 @@ def to_dict(obj: t.Mapping[T, T2]) -> t.Dict[T, T2]: ... @t.overload -def to_dict(obj: t.Iterable[T]) -> t.Dict[int, T]: ... +def to_dict(obj: t.Union[t.Iterator[T], t.Sequence[T]]) -> t.Dict[int, T]: ... @t.overload @@ -2140,7 +2148,7 @@ def to_pairs(obj: t.Mapping[T, T2]) -> t.List[t.Tuple[T, T2]]: ... @t.overload -def to_pairs(obj: t.Iterable[T]) -> t.List[t.Tuple[int, T]]: ... +def to_pairs(obj: t.Union[t.Iterator[T], t.Sequence[T]]) -> t.List[t.Tuple[int, T]]: ... @t.overload