Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type fixes #232

Merged
merged 2 commits into from
Jul 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/pydash/arrays.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
.. versionadded:: 1.0.0
"""

from __future__ import annotations

from bisect import bisect_left, bisect_right
from functools import cmp_to_key
from math import ceil
Expand Down
24 changes: 15 additions & 9 deletions src/pydash/chaining/all_funcs.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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):
Expand All @@ -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]]": ...
Expand Down Expand Up @@ -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):
Expand All @@ -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):
Expand Down
2 changes: 2 additions & 0 deletions src/pydash/numerical.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
.. versionadded:: 2.1.0
"""

from __future__ import annotations

import math
import operator
import typing as t
Expand Down
28 changes: 19 additions & 9 deletions src/pydash/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
.. versionadded:: 1.0.0
"""

from __future__ import annotations

import copy
from functools import partial
import math
Expand Down Expand Up @@ -925,10 +927,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.

Expand Down Expand Up @@ -967,11 +969,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):
Expand Down Expand Up @@ -1510,7 +1516,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
Expand Down Expand Up @@ -1564,11 +1570,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
Expand Down Expand Up @@ -1949,7 +1959,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
Expand Down Expand Up @@ -2140,7 +2150,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
Expand Down