diff --git a/stubs/openpyxl/openpyxl/worksheet/cell_range.pyi b/stubs/openpyxl/openpyxl/worksheet/cell_range.pyi index 9047a877351e..5923119f0d18 100644 --- a/stubs/openpyxl/openpyxl/worksheet/cell_range.pyi +++ b/stubs/openpyxl/openpyxl/worksheet/cell_range.pyi @@ -1,10 +1,12 @@ -from _typeshed import ConvertibleToInt, Incomplete -from collections.abc import Generator, Iterator +from _typeshed import ConvertibleToInt +from collections.abc import Generator, Iterable, Iterator from itertools import product from typing import Any, Literal, overload +from typing_extensions import Self from openpyxl.descriptors import Strict from openpyxl.descriptors.base import MinMax +from openpyxl.descriptors.sequence import UniqueSequence from openpyxl.descriptors.serialisable import Serialisable class CellRange(Serialisable): @@ -59,7 +61,7 @@ class CellRange(Serialisable): def cols(self) -> Generator[list[tuple[int, int]]]: ... @property def cells(self) -> product[tuple[int, int]]: ... - def __copy__(self): ... + def __copy__(self) -> Self: ... def shift(self, col_shift: int = 0, row_shift: int = 0) -> None: ... def __ne__(self, other: object) -> bool: ... def __eq__(self, other: object) -> bool: ... @@ -71,9 +73,9 @@ class CellRange(Serialisable): def __contains__(self, coord: str) -> bool: ... def __gt__(self, other: CellRange) -> bool: ... def isdisjoint(self, other: CellRange) -> bool: ... - def intersection(self, other): ... + def intersection(self, other: CellRange) -> CellRange: ... __and__ = intersection - def union(self, other): ... + def union(self, other: CellRange) -> CellRange: ... __or__ = union # Iterates over class attributes. Value could be anything. def __iter__(self) -> Iterator[tuple[str, Any]]: ... @@ -91,15 +93,15 @@ class CellRange(Serialisable): def right(self) -> list[tuple[int, int]]: ... class MultiCellRange(Strict): - ranges: Incomplete - def __init__(self, ranges=...) -> None: ... + ranges: UniqueSequence[CellRange] + def __init__(self, ranges: str | Iterable[CellRange | str] = ...) -> None: ... def __contains__(self, coord: str | CellRange) -> bool: ... def sorted(self) -> list[CellRange]: ... - def add(self, coord) -> None: ... - def __iadd__(self, coord): ... + def add(self, coord: str | CellRange) -> None: ... + def __iadd__(self, coord: str | CellRange) -> Self: ... def __eq__(self, other: str | MultiCellRange) -> bool: ... # type: ignore[override] def __ne__(self, other: str | MultiCellRange) -> bool: ... # type: ignore[override] def __bool__(self) -> bool: ... - def remove(self, coord) -> None: ... + def remove(self, coord: str | CellRange) -> None: ... def __iter__(self) -> Iterator[CellRange]: ... - def __copy__(self): ... + def __copy__(self) -> MultiCellRange: ...