From 37f7a61607430799be614b3f53de30d088adb2ff Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 5 Aug 2024 16:30:41 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.5.0 → v0.5.6](https://github.com/astral-sh/ruff-pre-commit/compare/v0.5.0...v0.5.6) - [github.com/asottile/pyupgrade: v3.16.0 → v3.17.0](https://github.com/asottile/pyupgrade/compare/v3.16.0...v3.17.0) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b81b9ba070a44..b307d4ad336c8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,7 +19,7 @@ ci: skip: [pyright, mypy] repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.5.0 + rev: v0.5.6 hooks: - id: ruff args: [--exit-non-zero-on-fix] @@ -73,7 +73,7 @@ repos: hooks: - id: isort - repo: https://github.com/asottile/pyupgrade - rev: v3.16.0 + rev: v3.17.0 hooks: - id: pyupgrade args: [--py310-plus] From 68b73413734ae3d2c7ddeab740fbff9ccdfbffad Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 5 Aug 2024 16:32:09 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pandas/_config/config.py | 4 ++-- pandas/_config/localization.py | 2 +- pandas/_testing/_warnings.py | 2 +- pandas/_testing/contexts.py | 8 ++++---- pandas/compat/pickle_compat.py | 2 +- pandas/core/apply.py | 6 +++--- pandas/core/arrays/datetimes.py | 2 +- pandas/core/common.py | 2 +- pandas/core/groupby/ops.py | 2 +- pandas/core/indexes/multi.py | 2 +- pandas/core/internals/blocks.py | 2 +- pandas/core/internals/concat.py | 2 +- pandas/core/internals/managers.py | 4 ++-- pandas/core/methods/to_dict.py | 2 +- pandas/io/formats/css.py | 6 +++--- pandas/io/formats/format.py | 2 +- pandas/io/sql.py | 6 +++--- pandas/plotting/_matplotlib/converter.py | 2 +- pandas/plotting/_matplotlib/tools.py | 2 +- pandas/plotting/_misc.py | 2 +- pandas/util/_exceptions.py | 4 ++-- 21 files changed, 33 insertions(+), 33 deletions(-) diff --git a/pandas/_config/config.py b/pandas/_config/config.py index 51794ec04b29e..01618e471c2b9 100644 --- a/pandas/_config/config.py +++ b/pandas/_config/config.py @@ -411,7 +411,7 @@ def __dir__(self) -> list[str]: @contextmanager -def option_context(*args) -> Generator[None, None, None]: +def option_context(*args) -> Generator[None]: """ Context manager to temporarily set options in a ``with`` statement. @@ -713,7 +713,7 @@ def _build_option_description(k: str) -> str: @contextmanager -def config_prefix(prefix: str) -> Generator[None, None, None]: +def config_prefix(prefix: str) -> Generator[None]: """ contextmanager for multiple invocations of API with a common prefix diff --git a/pandas/_config/localization.py b/pandas/_config/localization.py index 61d88c43f0e4a..6602633f20399 100644 --- a/pandas/_config/localization.py +++ b/pandas/_config/localization.py @@ -25,7 +25,7 @@ @contextmanager def set_locale( new_locale: str | tuple[str, str], lc_var: int = locale.LC_ALL -) -> Generator[str | tuple[str, str], None, None]: +) -> Generator[str | tuple[str, str]]: """ Context manager for temporarily setting a locale. diff --git a/pandas/_testing/_warnings.py b/pandas/_testing/_warnings.py index cd2e2b4141ffd..a752c8db90f38 100644 --- a/pandas/_testing/_warnings.py +++ b/pandas/_testing/_warnings.py @@ -35,7 +35,7 @@ def assert_produces_warning( raise_on_extra_warnings: bool = True, match: str | tuple[str | None, ...] | None = None, must_find_all_warnings: bool = True, -) -> Generator[list[warnings.WarningMessage], None, None]: +) -> Generator[list[warnings.WarningMessage]]: """ Context manager for running code expected to either raise a specific warning, multiple specific warnings, or not raise any warnings. Verifies that the code diff --git a/pandas/_testing/contexts.py b/pandas/_testing/contexts.py index 91b5d2a981bef..f041d8755bb64 100644 --- a/pandas/_testing/contexts.py +++ b/pandas/_testing/contexts.py @@ -29,7 +29,7 @@ @contextmanager def decompress_file( path: FilePath | BaseBuffer, compression: CompressionOptions -) -> Generator[IO[bytes], None, None]: +) -> Generator[IO[bytes]]: """ Open a compressed file and return a file object. @@ -50,7 +50,7 @@ def decompress_file( @contextmanager -def set_timezone(tz: str) -> Generator[None, None, None]: +def set_timezone(tz: str) -> Generator[None]: """ Context manager for temporarily setting a timezone. @@ -91,7 +91,7 @@ def setTZ(tz) -> None: @contextmanager -def ensure_clean(filename=None) -> Generator[Any, None, None]: +def ensure_clean(filename=None) -> Generator[Any]: """ Gets a temporary path and agrees to remove on close. @@ -123,7 +123,7 @@ def ensure_clean(filename=None) -> Generator[Any, None, None]: @contextmanager -def with_csv_dialect(name: str, **kwargs) -> Generator[None, None, None]: +def with_csv_dialect(name: str, **kwargs) -> Generator[None]: """ Context manager to temporarily register a CSV dialect for parsing CSV. diff --git a/pandas/compat/pickle_compat.py b/pandas/compat/pickle_compat.py index 28985a1380bee..beaaa3f8ed3cc 100644 --- a/pandas/compat/pickle_compat.py +++ b/pandas/compat/pickle_compat.py @@ -131,7 +131,7 @@ def loads( @contextlib.contextmanager -def patch_pickle() -> Generator[None, None, None]: +def patch_pickle() -> Generator[None]: """ Temporarily patch pickle to use our unpickler. """ diff --git a/pandas/core/apply.py b/pandas/core/apply.py index 5959156d11123..ac336713a70f3 100644 --- a/pandas/core/apply.py +++ b/pandas/core/apply.py @@ -806,7 +806,7 @@ def result_columns(self) -> Index: @property @abc.abstractmethod - def series_generator(self) -> Generator[Series, None, None]: + def series_generator(self) -> Generator[Series]: pass @staticmethod @@ -1131,7 +1131,7 @@ class FrameRowApply(FrameApply): axis: AxisInt = 0 @property - def series_generator(self) -> Generator[Series, None, None]: + def series_generator(self) -> Generator[Series]: return (self.obj._ixs(i, axis=1) for i in range(len(self.columns))) @staticmethod @@ -1243,7 +1243,7 @@ def apply_broadcast(self, target: DataFrame) -> DataFrame: return result.T @property - def series_generator(self) -> Generator[Series, None, None]: + def series_generator(self) -> Generator[Series]: values = self.values values = ensure_wrapped_if_datetimelike(values) assert len(values) > 0 diff --git a/pandas/core/arrays/datetimes.py b/pandas/core/arrays/datetimes.py index dddfc440109d3..5f9bc0fab1dbc 100644 --- a/pandas/core/arrays/datetimes.py +++ b/pandas/core/arrays/datetimes.py @@ -2906,7 +2906,7 @@ def _generate_range( offset: BaseOffset, *, unit: str, -) -> Generator[Timestamp, None, None]: +) -> Generator[Timestamp]: """ Generates a sequence of dates corresponding to the specified time offset. Similar to dateutil.rrule except uses pandas DateOffset diff --git a/pandas/core/common.py b/pandas/core/common.py index ec0473a20458b..642f14442b53e 100644 --- a/pandas/core/common.py +++ b/pandas/core/common.py @@ -562,7 +562,7 @@ def convert_to_list_like( @contextlib.contextmanager def temp_setattr( obj, attr: str, value, condition: bool = True -) -> Generator[None, None, None]: +) -> Generator[None]: """ Temporarily set attribute on an object. diff --git a/pandas/core/groupby/ops.py b/pandas/core/groupby/ops.py index da80969b613cd..008fe9bdee5bd 100644 --- a/pandas/core/groupby/ops.py +++ b/pandas/core/groupby/ops.py @@ -865,7 +865,7 @@ def _unob_index_and_ids( return unob_index, unob_ids @final - def get_group_levels(self) -> Generator[Index, None, None]: + def get_group_levels(self) -> Generator[Index]: # Note: only called from _insert_inaxis_grouper, which # is only called for BaseGrouper, never for BinGrouper result_index = self.result_index diff --git a/pandas/core/indexes/multi.py b/pandas/core/indexes/multi.py index 799b6f32c1387..19fa056a5f25a 100644 --- a/pandas/core/indexes/multi.py +++ b/pandas/core/indexes/multi.py @@ -2623,7 +2623,7 @@ def _reorder_ilevels(self, order) -> MultiIndex: def _recode_for_new_levels( self, new_levels, copy: bool = True - ) -> Generator[np.ndarray, None, None]: + ) -> Generator[np.ndarray]: if len(new_levels) > self.nlevels: raise AssertionError( f"Length of new_levels ({len(new_levels)}) " diff --git a/pandas/core/internals/blocks.py b/pandas/core/internals/blocks.py index 149bef6258bfa..92ba484427649 100644 --- a/pandas/core/internals/blocks.py +++ b/pandas/core/internals/blocks.py @@ -388,7 +388,7 @@ def _split_op_result(self, result: ArrayLike) -> list[Block]: return [nb] @final - def _split(self) -> Generator[Block, None, None]: + def _split(self) -> Generator[Block]: """ Split a block into a list of single-column blocks. """ diff --git a/pandas/core/internals/concat.py b/pandas/core/internals/concat.py index b96d5a59effce..2ee7d3948a70f 100644 --- a/pandas/core/internals/concat.py +++ b/pandas/core/internals/concat.py @@ -250,7 +250,7 @@ def _concat_homogeneous_fastpath( def _get_combined_plan( mgrs: list[BlockManager], -) -> Generator[tuple[BlockPlacement, list[JoinUnit]], None, None]: +) -> Generator[tuple[BlockPlacement, list[JoinUnit]]]: max_len = mgrs[0].shape[0] blknos_list = [mgr.blknos for mgr in mgrs] diff --git a/pandas/core/internals/managers.py b/pandas/core/internals/managers.py index c42ea44b2fc89..342ab188042e6 100644 --- a/pandas/core/internals/managers.py +++ b/pandas/core/internals/managers.py @@ -856,7 +856,7 @@ def _slice_take_blocks_ax0( *, use_na_proxy: bool = False, ref_inplace_op: bool = False, - ) -> Generator[Block, None, None]: + ) -> Generator[Block]: """ Slice/take blocks along axis=0. @@ -1731,7 +1731,7 @@ def unstack(self, unstacker, fill_value) -> BlockManager: bm = BlockManager(new_blocks, [new_columns, new_index], verify_integrity=False) return bm - def to_iter_dict(self) -> Generator[tuple[str, Self], None, None]: + def to_iter_dict(self) -> Generator[tuple[str, Self]]: """ Yield a tuple of (str(dtype), BlockManager) diff --git a/pandas/core/methods/to_dict.py b/pandas/core/methods/to_dict.py index 84202a4fcc840..aea95e4684573 100644 --- a/pandas/core/methods/to_dict.py +++ b/pandas/core/methods/to_dict.py @@ -33,7 +33,7 @@ def create_data_for_split( df: DataFrame, are_all_object_dtype_cols: bool, object_dtype_indices: list[int] -) -> Generator[list, None, None]: +) -> Generator[list]: """ Simple helper method to create data for to ``to_dict(orient="split")`` to create the main output data diff --git a/pandas/io/formats/css.py b/pandas/io/formats/css.py index 0af04526ea96d..750c6dc1180e9 100644 --- a/pandas/io/formats/css.py +++ b/pandas/io/formats/css.py @@ -36,7 +36,7 @@ def _side_expander(prop_fmt: str) -> Callable: def expand( self: CSSResolver, prop: str, value: str - ) -> Generator[tuple[str, str], None, None]: + ) -> Generator[tuple[str, str]]: """ Expand shorthand property into side-specific property (top, right, bottom, left) @@ -83,7 +83,7 @@ def _border_expander(side: str = "") -> Callable: def expand( self: CSSResolver, prop: str, value: str - ) -> Generator[tuple[str, str], None, None]: + ) -> Generator[tuple[str, str]]: """ Expand border into color, style, and width tuples @@ -392,7 +392,7 @@ def _error() -> str: size_fmt = f"{val:f}pt" return size_fmt - def atomize(self, declarations: Iterable) -> Generator[tuple[str, str], None, None]: + def atomize(self, declarations: Iterable) -> Generator[tuple[str, str]]: for prop, value in declarations: prop = prop.lower() value = value.lower() diff --git a/pandas/io/formats/format.py b/pandas/io/formats/format.py index 9ad5ac83e9eae..5aecc6af712e5 100644 --- a/pandas/io/formats/format.py +++ b/pandas/io/formats/format.py @@ -1024,7 +1024,7 @@ def save_to_buffer( @contextmanager def _get_buffer( buf: FilePath | WriteBuffer[str] | None, encoding: str | None = None -) -> Generator[WriteBuffer[str], None, None] | Generator[StringIO, None, None]: +) -> Generator[WriteBuffer[str]] | Generator[StringIO]: """ Context manager to open, yield and close buffer for filenames or Path-like objects, otherwise yield buf unchanged. diff --git a/pandas/io/sql.py b/pandas/io/sql.py index 4fd7de7a28855..c144591df6c72 100644 --- a/pandas/io/sql.py +++ b/pandas/io/sql.py @@ -1116,7 +1116,7 @@ def _query_iterator( coerce_float: bool = True, parse_dates=None, dtype_backend: DtypeBackend | Literal["numpy"] = "numpy", - ) -> Generator[DataFrame, None, None]: + ) -> Generator[DataFrame]: """Return generator through chunked result set.""" has_read_data = False with exit_stack: @@ -1728,7 +1728,7 @@ def _query_iterator( parse_dates=None, dtype: DtypeArg | None = None, dtype_backend: DtypeBackend | Literal["numpy"] = "numpy", - ) -> Generator[DataFrame, None, None]: + ) -> Generator[DataFrame]: """Return generator through chunked result set""" has_read_data = False with exit_stack: @@ -2677,7 +2677,7 @@ def _query_iterator( parse_dates=None, dtype: DtypeArg | None = None, dtype_backend: DtypeBackend | Literal["numpy"] = "numpy", - ) -> Generator[DataFrame, None, None]: + ) -> Generator[DataFrame]: """Return generator through chunked result set""" has_read_data = False while True: diff --git a/pandas/plotting/_matplotlib/converter.py b/pandas/plotting/_matplotlib/converter.py index fc63d65f1e160..29f9b3ee116fc 100644 --- a/pandas/plotting/_matplotlib/converter.py +++ b/pandas/plotting/_matplotlib/converter.py @@ -92,7 +92,7 @@ def wrapper(*args, **kwargs): @contextlib.contextmanager -def pandas_converters() -> Generator[None, None, None]: +def pandas_converters() -> Generator[None]: """ Context manager registering pandas' converters for a plot. diff --git a/pandas/plotting/_matplotlib/tools.py b/pandas/plotting/_matplotlib/tools.py index f9c370b2486fd..d5624aecd1215 100644 --- a/pandas/plotting/_matplotlib/tools.py +++ b/pandas/plotting/_matplotlib/tools.py @@ -442,7 +442,7 @@ def handle_shared_axes( _remove_labels_from_axis(ax.yaxis) -def flatten_axes(axes: Axes | Iterable[Axes]) -> Generator[Axes, None, None]: +def flatten_axes(axes: Axes | Iterable[Axes]) -> Generator[Axes]: if not is_list_like(axes): yield axes # type: ignore[misc] elif isinstance(axes, (np.ndarray, ABCIndex)): diff --git a/pandas/plotting/_misc.py b/pandas/plotting/_misc.py index d8455f44ef0d1..1ebf1b16d419e 100644 --- a/pandas/plotting/_misc.py +++ b/pandas/plotting/_misc.py @@ -704,7 +704,7 @@ def _get_canonical_key(self, key: str) -> str: return self._ALIASES.get(key, key) @contextmanager - def use(self, key, value) -> Generator[_Options, None, None]: + def use(self, key, value) -> Generator[_Options]: """ Temporarily set a parameter value using the with statement. Aliasing allowed. diff --git a/pandas/util/_exceptions.py b/pandas/util/_exceptions.py index 5f50838d37315..f77f3f9083901 100644 --- a/pandas/util/_exceptions.py +++ b/pandas/util/_exceptions.py @@ -13,7 +13,7 @@ @contextlib.contextmanager -def rewrite_exception(old_name: str, new_name: str) -> Generator[None, None, None]: +def rewrite_exception(old_name: str, new_name: str) -> Generator[None]: """ Rewrite the message of an exception. """ @@ -66,7 +66,7 @@ def rewrite_warning( target_category: type[Warning], new_message: str, new_category: type[Warning] | None = None, -) -> Generator[None, None, None]: +) -> Generator[None]: """ Rewrite the message of a warning.