Skip to content

Commit 0dda21b

Browse files
committed
Improve typing.
1 parent 5a5173a commit 0dda21b

File tree

4 files changed

+18
-43
lines changed

4 files changed

+18
-43
lines changed

iters/async_utils.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ async def async_iter_function_await(function: AsyncNullary[T], sentinel: V) -> A
434434

435435
async def async_empty() -> AsyncIterator[Never]:
436436
return
437-
yield # type: ignore
437+
yield
438438

439439

440440
async def async_of(*items: T) -> AsyncIterator[T]:
@@ -782,7 +782,7 @@ async def async_reduce(
782782
if is_marker(initial):
783783
raise ValueError(ASYNC_REDUCE_ON_EMPTY)
784784

785-
return await async_fold(initial, function, iterator) # type: ignore
785+
return await async_fold(initial, function, iterator)
786786

787787

788788
ASYNC_REDUCE_AWAIT_ON_EMPTY = "async_reduce_await() called on an empty iterable"
@@ -813,7 +813,7 @@ async def async_reduce_await(
813813

814814
return default
815815

816-
return await async_fold_await(initial, function, iterator) # type: ignore
816+
return await async_fold_await(initial, function, iterator)
817817

818818

819819
async def async_accumulate_fold(
@@ -2074,7 +2074,7 @@ async def async_walk(node: RecursiveAnyIterable[T]) -> AsyncIterator[T]:
20742074

20752075
else:
20762076
async for child in tree:
2077-
async for nested in async_walk(child): # type: ignore
2077+
async for nested in async_walk(child):
20782078
yield nested
20792079

20802080

@@ -5046,12 +5046,12 @@ def async_cartesian_product(*iterables: AnyIterable[Any]) -> AsyncIterator[Dynam
50465046
return stack
50475047

50485048

5049-
Ts = TypeVarTuple("Ts") # type: ignore
5049+
Ts = TypeVarTuple("Ts")
50505050

50515051

50525052
async def async_cartesian_product_step(
5053-
stack: AnyIterable[Tuple[Unpack[Ts]]], iterable: AnyIterable[T] # type: ignore
5054-
) -> AsyncIterator[Tuple[Unpack[Ts], T]]: # type: ignore
5053+
stack: AnyIterable[Tuple[Unpack[Ts]]], iterable: AnyIterable[T]
5054+
) -> AsyncIterator[Tuple[Unpack[Ts], T]]:
50555055
array = await async_list(iterable)
50565056

50575057
async for items in async_iter(stack):
@@ -5113,8 +5113,8 @@ def async_cartesian_power(power: int, iterable: AnyIterable[T]) -> AsyncIterator
51135113
state = None
51145114

51155115
async def async_cartesian_power_step(
5116-
stack: AnyIterable[Tuple[Unpack[Ts]]], # type: ignore
5117-
) -> AsyncIterator[Tuple[Unpack[Ts], T]]: # type: ignore
5116+
stack: AnyIterable[Tuple[Unpack[Ts]]],
5117+
) -> AsyncIterator[Tuple[Unpack[Ts], T]]:
51185118
nonlocal state
51195119

51205120
if state is None:

iters/ordered_set.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ def apply_intersection(self, *iterables: Iterable[Q]) -> OrderedSet[Q]:
570570
The intersection of the ordered set and `iterables`.
571571
"""
572572
if iterables:
573-
intersection = set.intersection(*map(set, iterables)) # type: ignore
573+
intersection = set.intersection(*map(set, iterables))
574574

575575
iterator = (item for item in self if item in intersection)
576576

@@ -606,7 +606,7 @@ def apply_difference(self, *iterables: Iterable[Q]) -> OrderedSet[Q]:
606606
The difference of the ordered set and `iterables`.
607607
"""
608608
if iterables:
609-
union = set.union(*map(set, iterables)) # type: ignore
609+
union = set.union(*map(set, iterables))
610610
iterator = (item for item in self if item not in union)
611611

612612
return self.create_unchecked(iterator)

iters/utils.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,6 @@
213213
"zip_longest",
214214
)
215215

216-
PYTHON_3_8 = version_info >= (3, 8, 0)
217-
PYTHON_3_10 = version_info >= (3, 10, 0)
218-
219216
T = TypeVar("T")
220217
U = TypeVar("U")
221218
V = TypeVar("V")
@@ -309,7 +306,7 @@ def iter_function(function: Nullary[T], sentinel: V) -> Iterator[T]:
309306

310307
def empty() -> Iterator[Never]:
311308
return
312-
yield # type: ignore
309+
yield
313310

314311

315312
def once(value: T) -> Iterator[T]:
@@ -477,10 +474,10 @@ def accumulate_reduce(function: Binary[T, T, T], iterable: Iterable[T]) -> Itera
477474

478475

479476
def accumulate_fold(initial: U, function: Binary[U, T, U], iterable: Iterable[T]) -> Iterator[U]:
480-
if PYTHON_3_8:
481-
return standard_accumulate(iterable, function, initial=initial) # type: ignore
477+
if version_info >= (3, 8, 0):
478+
return standard_accumulate(iterable, function, initial=initial)
482479

483-
return standard_accumulate(prepend(initial, iterable), function) # type: ignore
480+
return standard_accumulate(prepend(initial, iterable), function) # type: ignore[arg-type]
484481

485482

486483
@overload
@@ -2396,8 +2393,8 @@ def zip_equal( # type: ignore
23962393

23972394

23982395
def zip_equal(*iterables: Iterable[Any]) -> Iterator[DynamicTuple[Any]]:
2399-
if PYTHON_3_10:
2400-
return standard_zip(*iterables, strict=True) # type: ignore
2396+
if version_info >= (3, 10, 0):
2397+
return standard_zip(*iterables, strict=True)
24012398

24022399
return zip_equal_simple(*iterables)
24032400

pyproject.toml

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -123,29 +123,7 @@ exclude_lines = [
123123
directory = "coverage"
124124

125125
[tool.mypy]
126-
show_column_numbers = true
127-
128-
disallow_any_decorated = true
129-
disallow_any_generics = true
130-
warn_return_any = true
131-
132-
no_implicit_optional = true
133-
strict_optional = true
134-
135-
strict_equality = true
136-
137-
disallow_untyped_calls = true
138-
disallow_untyped_defs = true
139-
disallow_untyped_decorators = true
140-
disallow_untyped_globals = true
141-
142-
disallow_incomplete_defs = true
143-
144-
warn_no_return = true
145-
warn_unreachable = true
146-
147-
warn_redundant_casts = true
148-
warn_unused_ignores = false # compatibility
126+
strict = true
149127

150128
[tool.changelogging]
151129
name = "iters"

0 commit comments

Comments
 (0)