Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonGrace2282 committed May 8, 2024
1 parent a82de37 commit 7ff507f
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions manim/utils/iterables.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def all_elements_are_instances(iterable: Iterable[object], Class: type[object])


def batch_by_property(
items: Sequence[T], property_func: Callable[[T], U]
items: Iterable[T], property_func: Callable[[T], U]
) -> list[tuple[list[T], U]]:
"""Takes in a Sequence, and returns a list of tuples, (batch, prop)
such that all items in a batch have the same output when
Expand Down Expand Up @@ -174,7 +174,7 @@ def listify(obj: Iterable[T]) -> list[T]: ...
def listify(obj: T) -> list[T]: ...

Check notice

Code scanning / CodeQL

Statement has no effect Note

This statement has no effect.


def listify(obj):
def listify(obj: str | Iterable[T] | T) -> list[str] | list[T]:
"""Converts obj to a list intelligently.
Examples
Expand All @@ -190,15 +190,15 @@ def listify(obj):
"""
if isinstance(obj, str):
return [obj]
try:
if isinstance(obj, Iterable):
return list(obj)
except TypeError:
else:
return [obj]


def make_even(
iterable_1: Iterable[T], iterable_2: Iterable[U]
) -> tuple[list[T | U], list[T | U]]:
) -> tuple[list[T], list[U]]:
"""Extends the shorter of the two iterables with duplicate values until its
length is equal to the longer iterable (favours earlier elements).
Expand Down Expand Up @@ -228,7 +228,7 @@ def make_even(

def make_even_by_cycling(
iterable_1: Collection[T], iterable_2: Collection[U]
) -> tuple[list[T | U], list[T | U]]:
) -> tuple[list[T], list[U]]:
"""Extends the shorter of the two iterables with duplicate values until its
length is equal to the longer iterable (cycles over shorter iterable).
Expand Down Expand Up @@ -269,7 +269,7 @@ def remove_list_redundancies(lst: Reversible[H]) -> list[H]:
return reversed_result


def remove_nones(sequence: Iterable) -> list:
def remove_nones(sequence: Iterable[T | None]) -> list[T]:
"""Removes elements where bool(x) evaluates to False.
Examples
Expand Down Expand Up @@ -422,7 +422,7 @@ def tuplify(obj: Iterable[T]) -> tuple[T]: ...
def tuplify(obj: T) -> tuple[T]: ...

Check notice

Code scanning / CodeQL

Statement has no effect Note

This statement has no effect.


def tuplify(obj):
def tuplify(obj: str | Iterable[T] | T) -> tuple[str] | tuple[T]:
"""Converts obj to a tuple intelligently.
Examples
Expand All @@ -438,9 +438,9 @@ def tuplify(obj):
"""
if isinstance(obj, str):
return (obj,)
try:
if isinstance(obj, Iterable):
return tuple(obj)
except TypeError:
else:
return (obj,)


Expand Down

0 comments on commit 7ff507f

Please sign in to comment.