Skip to content

Commit

Permalink
openpyxl: Reduce false-positives in Worksheet.__getitem__ (#11717)
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam authored Apr 7, 2024
1 parent 4157cb6 commit e922682
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions stubs/openpyxl/openpyxl/worksheet/worksheet.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,15 @@ class Worksheet(_WorkbookChild):
@freeze_panes.setter
def freeze_panes(self, topLeftCell: str | Cell | None = ...) -> None: ...
def cell(self, row: int, column: int, value: str | None = None) -> Cell: ...
# An int is necessarily a row selection
@overload
def __getitem__(self, key: int | slice) -> tuple[Cell, ...]: ...
def __getitem__(self, key: int) -> tuple[Cell, ...]: ...
# A slice is necessarily a row or rows, even if targetting a single cell
@overload
def __getitem__(self, key: str) -> Any: ... # AnyOf[Cell, tuple[Cell, ...]]
def __getitem__(self, key: slice) -> tuple[Any, ...]: ... # tuple[AnyOf[Cell, tuple[Cell, ...]]]
# A str could be an individual cell, row, column or full range
@overload
def __getitem__(self, key: str) -> Any: ... # AnyOf[Cell, tuple[Cell, ...], tuple[tuple[Cell, ...], ...]]
def __setitem__(self, key: str, value: str) -> None: ...
def __iter__(self) -> Iterator[tuple[Cell, ...]]: ...
def __delitem__(self, key: str) -> None: ...
Expand Down

0 comments on commit e922682

Please sign in to comment.