Skip to content

Commit 37807d7

Browse files
authored
Use Generator instead of Iterator for 3rd-party context managers (#12481)
1 parent 0b6f15c commit 37807d7

File tree

14 files changed

+22
-22
lines changed

14 files changed

+22
-22
lines changed

stubs/fpdf2/fpdf/drawing.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import decimal
22
from _typeshed import Incomplete
33
from collections import OrderedDict
4-
from collections.abc import Callable, Generator, Iterator, Sequence
4+
from collections.abc import Callable, Generator, Sequence
55
from contextlib import contextmanager
66
from re import Pattern
77
from typing import Any, ClassVar, Literal, NamedTuple, TypeVar, overload
@@ -354,7 +354,7 @@ class PaintedPath:
354354
@clipping_path.setter
355355
def clipping_path(self, new_clipath) -> None: ...
356356
@contextmanager
357-
def transform_group(self, transform) -> Iterator[Self]: ...
357+
def transform_group(self, transform) -> Generator[Self]: ...
358358
def add_path_element(self, item, _copy: bool = True) -> None: ...
359359
def remove_last_path_element(self) -> None: ...
360360
def rectangle(self, x, y, w, h, rx: int = 0, ry: int = 0) -> Self: ...

stubs/fpdf2/fpdf/fpdf.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ class FPDF(GraphicsStateMixin):
426426
def skew(
427427
self, ax: float = 0, ay: float = 0, x: float | None = None, y: float | None = None
428428
) -> _GeneratorContextManager[None]: ...
429-
def mirror(self, origin, angle) -> Generator[None, None, None]: ...
429+
def mirror(self, origin, angle) -> Generator[None]: ...
430430
def local_context(
431431
self,
432432
font_family: Incomplete | None = None,

stubs/google-cloud-ndb/google/cloud/ndb/client.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from _typeshed import Incomplete
2-
from collections.abc import Callable, Iterator
2+
from collections.abc import Callable, Generator
33
from contextlib import contextmanager
44
from typing import ClassVar
55

@@ -32,4 +32,4 @@ class Client:
3232
global_cache_policy: Callable[[key.Key], bool] | None = ...,
3333
global_cache_timeout_policy: Callable[[key.Key], int] | None = ...,
3434
legacy_data: bool = ...,
35-
) -> Iterator[context_module.Context]: ...
35+
) -> Generator[context_module.Context]: ...

stubs/jsonschema/jsonschema/validators.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class RefResolver:
107107
@property
108108
def base_uri(self): ...
109109
@contextmanager
110-
def in_scope(self, scope) -> Generator[None, None, None]: ...
110+
def in_scope(self, scope) -> Generator[None]: ...
111111
@contextmanager
112112
def resolving(self, ref) -> Generator[Incomplete, None, None]: ...
113113
def resolve(self, ref): ...

stubs/peewee/peewee.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class Context:
9898
def __exit__(
9999
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
100100
) -> None: ...
101-
def push_alias(self) -> Generator[None, None, None]: ...
101+
def push_alias(self) -> Generator[None]: ...
102102
def sql(self, obj): ...
103103
def literal(self, keyword): ...
104104
def value(self, value, converter: Incomplete | None = ..., add_param: bool = ...): ...

stubs/pyflakes/pyflakes/checker.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import ast
22
import sys
3-
from collections.abc import Callable, Iterable, Iterator
3+
from collections.abc import Callable, Generator, Iterable, Iterator
44
from contextlib import contextmanager
55
from re import Pattern
66
from typing import Any, ClassVar, Literal, TypeVar, overload
@@ -203,7 +203,7 @@ class Checker:
203203
@property
204204
def scope(self) -> Scope: ...
205205
@contextmanager
206-
def in_scope(self, cls: Callable[[], Scope]) -> Iterator[None]: ...
206+
def in_scope(self, cls: Callable[[], Scope]) -> Generator[None]: ...
207207
def checkDeadScopes(self) -> None: ...
208208
def report(self, messageClass: Callable[_P, Message], *args: _P.args, **kwargs: _P.kwargs) -> None: ...
209209
def getParent(self, node: ast.AST) -> ast.AST: ...

stubs/pygit2/pygit2/utils.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import contextlib
22
import types
33
from _typeshed import StrOrBytesPath, StrPath
4-
from collections.abc import Iterator
4+
from collections.abc import Generator
55
from typing import Generic, TypeVar
66
from typing_extensions import TypeAlias
77

@@ -12,7 +12,7 @@ def to_bytes(s: _CDataBase | StrOrBytesPath | None, encoding: str = "utf-8", err
1212
def to_str(s: StrOrBytesPath) -> str: ...
1313
def ptr_to_bytes(ptr_cdata: _CDataBase) -> bytes: ...
1414
@contextlib.contextmanager
15-
def new_git_strarray() -> Iterator[_GitStrArray]: ...
15+
def new_git_strarray() -> Generator[_GitStrArray]: ...
1616
def strarray_to_strings(arr: _GitStrArray) -> list[str]: ...
1717

1818
# Actual type: _cffi_backend.__CDataOwn <cdata 'struct git_strarray *'>

stubs/pynput/pynput/keyboard/_base.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import contextlib
22
import enum
33
import sys
4-
from collections.abc import Callable, Iterable, Iterator
4+
from collections.abc import Callable, Generator, Iterable, Iterator
55
from typing import Any, ClassVar
66
from typing_extensions import Self
77

@@ -108,7 +108,7 @@ class Controller:
108108
def tap(self, key: str | Key | KeyCode) -> None: ...
109109
def touch(self, key: str | Key | KeyCode, is_press: bool) -> None: ...
110110
@contextlib.contextmanager
111-
def pressed(self, *args: str | Key | KeyCode) -> Iterator[None]: ...
111+
def pressed(self, *args: str | Key | KeyCode) -> Generator[None]: ...
112112
def type(self, string: str) -> None: ...
113113
@property
114114
def modifiers(self) -> contextlib.AbstractContextManager[Iterator[set[Key]]]: ...

stubs/seaborn/seaborn/_core/plot.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class PairSpec(TypedDict, total=False):
4646
wrap: int | None
4747

4848
@contextmanager
49-
def theme_context(params: dict[str, Any]) -> Generator[None, None, None]: ...
49+
def theme_context(params: dict[str, Any]) -> Generator[None]: ...
5050
def build_plot_signature(cls: _ClsT) -> _ClsT: ... # -> _ClsT & "__signature__ protocol"
5151

5252
class ThemeConfig(mpl.RcParams):

stubs/setuptools/setuptools/wheel.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ WHEEL_NAME: Incomplete
55
NAMESPACE_PACKAGE_INIT: str
66

77
def unpack(src_dir, dst_dir) -> None: ...
8-
def disable_info_traces() -> Generator[None, None, None]: ...
8+
def disable_info_traces() -> Generator[None]: ...
99

1010
class Wheel:
1111
filename: Incomplete

stubs/tensorflow/tensorflow/__init__.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import abc
22
from _typeshed import Incomplete, Unused
33
from abc import ABC, ABCMeta, abstractmethod
44
from builtins import bool as _bool
5-
from collections.abc import Callable, Iterable, Iterator, Sequence
5+
from collections.abc import Callable, Generator, Iterable, Iterator, Sequence
66
from contextlib import contextmanager
77
from enum import Enum
88
from types import TracebackType
@@ -228,7 +228,7 @@ class Graph:
228228
def add_to_collection(self, name: str, value: object) -> None: ...
229229
def add_to_collections(self, names: Iterable[str] | str, value: object) -> None: ...
230230
@contextmanager
231-
def as_default(self) -> Iterator[Self]: ...
231+
def as_default(self) -> Generator[Self]: ...
232232
def finalize(self) -> None: ...
233233
def get_tensor_by_name(self, name: str) -> Tensor: ...
234234
def get_operation_by_name(self, name: str) -> Operation: ...

stubs/tensorflow/tensorflow/autodiff.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class GradientTape:
5656
unconnected_gradients: UnconnectedGradients = ...,
5757
) -> ContainerGradients: ...
5858
@contextmanager
59-
def stop_recording(self) -> Generator[None, None, None]: ...
59+
def stop_recording(self) -> Generator[None]: ...
6060
def reset(self) -> None: ...
6161
def watch(self, tensor: ContainerTensorsLike) -> None: ...
6262
def watched_variables(self) -> tuple[Variable, ...]: ...

stubs/tensorflow/tensorflow/summary.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import abc
22
from _typeshed import Incomplete
3-
from collections.abc import Callable, Iterator
3+
from collections.abc import Callable, Generator
44
from contextlib import AbstractContextManager, contextmanager
55
from typing import Literal
66
from typing_extensions import Self
@@ -49,7 +49,7 @@ def image(
4949
description: str | None = None,
5050
) -> bool: ...
5151
@contextmanager
52-
def record_if(condition: bool | tf.Tensor | Callable[[], bool]) -> Iterator[None]: ...
52+
def record_if(condition: bool | tf.Tensor | Callable[[], bool]) -> Generator[None]: ...
5353
def scalar(name: str, data: float | tf.Tensor, step: int | tf.Tensor | None = None, description: str | None = None) -> bool: ...
5454
def should_record_summaries() -> bool: ...
5555
def text(name: str, data: str | tf.Tensor, step: int | tf.Tensor | None = None, description: str | None = None) -> bool: ...

tests/regr_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import sys
1414
import tempfile
1515
import threading
16-
from collections.abc import Callable, Iterator
16+
from collections.abc import Callable, Generator
1717
from contextlib import ExitStack, contextmanager, suppress
1818
from dataclasses import dataclass
1919
from enum import IntEnum
@@ -316,7 +316,7 @@ def concurrently_run_testcases(
316316
@contextmanager
317317
def cleanup_threads(
318318
event: threading.Event, printer_thread: threading.Thread, executor: concurrent.futures.ThreadPoolExecutor
319-
) -> Iterator[None]:
319+
) -> Generator[None]:
320320
try:
321321
yield
322322
except:

0 commit comments

Comments
 (0)