Skip to content

Commit

Permalink
openpyxl: Simpler leftover changes from the `microsoft/python-type-…
Browse files Browse the repository at this point in the history
…stubs` merge (#11534)
  • Loading branch information
Avasam authored Mar 8, 2024
1 parent 7c29ee3 commit 82fd9e8
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 20 deletions.
4 changes: 2 additions & 2 deletions stubs/openpyxl/openpyxl/cell/cell.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ class MergedCell(StyleableObject):
data_type: str
comment: Comment | None
hyperlink: Hyperlink | None
row: int
column: int
row: int | None
column: int | None
def __init__(self, worksheet: Worksheet, row: int | None = None, column: int | None = None) -> None: ...
# Same as Cell.coordinate
@property
Expand Down
3 changes: 1 addition & 2 deletions stubs/openpyxl/openpyxl/reader/excel.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from _typeshed import Incomplete
from typing import Final, Literal
from typing_extensions import TypeAlias
from zipfile import ZipFile
Expand All @@ -21,7 +20,7 @@ class ExcelReader:
data_only: bool
keep_links: bool
rich_text: bool
shared_strings: list[Incomplete]
shared_strings: list[str]
package: Manifest # defined after call to read_manifest()
parser: WorkbookParser # defined after call to read_workbook()
wb: Workbook # defined after call to read_workbook()
Expand Down
7 changes: 6 additions & 1 deletion stubs/openpyxl/openpyxl/workbook/workbook.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ from zipfile import ZipFile
from openpyxl import _Decodable, _ZipFileFileProtocol
from openpyxl.chartsheet.chartsheet import Chartsheet
from openpyxl.styles.named_styles import NamedStyle
from openpyxl.utils.indexed_list import IndexedList
from openpyxl.workbook.child import _WorkbookChild
from openpyxl.worksheet._read_only import ReadOnlyWorksheet
from openpyxl.worksheet._write_only import WriteOnlyWorksheet
from openpyxl.worksheet.worksheet import Worksheet

Expand All @@ -20,7 +22,7 @@ class Workbook:
defined_names: Incomplete
properties: Incomplete
security: Incomplete
shared_strings: Incomplete
shared_strings: IndexedList[str]
loaded_theme: Incomplete
vba_archive: ZipFile | None
is_template: bool
Expand All @@ -30,6 +32,9 @@ class Workbook:
rels: Incomplete
calculation: Incomplete
views: Incomplete
# Private, but useful as a reference of what "sheets" can be for other types
# ExcelReader can add ReadOnlyWorksheet in read_only mode.
_sheets: list[Worksheet | WriteOnlyWorksheet | Chartsheet | ReadOnlyWorksheet]
def __init__(self, write_only: bool = False, iso_dates: bool = False) -> None: ...
@property
def epoch(self) -> datetime: ...
Expand Down
4 changes: 2 additions & 2 deletions stubs/openpyxl/openpyxl/worksheet/_read_only.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from _typeshed import Incomplete
from _typeshed import Incomplete, SupportsGetItem
from collections.abc import Generator

from openpyxl import _VisibilityType
Expand All @@ -23,7 +23,7 @@ class ReadOnlyWorksheet:
parent: Incomplete
title: str
sheet_state: _VisibilityType
def __init__(self, parent_workbook, title: str, worksheet_path, shared_strings) -> None: ...
def __init__(self, parent_workbook, title: str, worksheet_path, shared_strings: SupportsGetItem[int, str]) -> None: ...
def calculate_dimension(self, force: bool = False): ...
def reset_dimensions(self) -> None: ...
@property
Expand Down
20 changes: 12 additions & 8 deletions stubs/openpyxl/openpyxl/worksheet/_reader.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from _typeshed import Incomplete, SupportsGetItem, Unused
from collections.abc import Container, Generator
from datetime import datetime
from typing import Final
from typing import Any, Final
from xml.etree.ElementTree import _FileRead

from openpyxl.cell.cell import Cell
from openpyxl.cell.rich_text import CellRichText
from openpyxl.descriptors.serialisable import _ChildSerialisableTreeElement, _SerialisableTreeElement
from openpyxl.formula.translate import Translator
from openpyxl.utils.cell import _RangeBoundariesTuple

from ..xml._functions_overloads import _HasAttrib, _SupportsIterAndAttrib
Expand Down Expand Up @@ -50,9 +52,9 @@ class WorkSheetParser:
min_col: Incomplete | None
epoch: datetime
source: _FileRead
shared_strings: SupportsGetItem[int, Incomplete]
shared_strings: SupportsGetItem[int, str]
data_only: bool
shared_formulae: dict[Incomplete, Incomplete]
shared_formulae: dict[Incomplete, Translator]
row_counter: int
col_counter: int
tables: TablePartList
Expand All @@ -74,7 +76,7 @@ class WorkSheetParser:
def __init__(
self,
src: _FileRead,
shared_strings: SupportsGetItem[int, Incomplete],
shared_strings: SupportsGetItem[int, str],
data_only: bool = False,
epoch: datetime = ...,
date_formats: Container[int] = ...,
Expand All @@ -83,10 +85,12 @@ class WorkSheetParser:
) -> None: ...
def parse(self) -> Generator[Incomplete, None, None]: ...
def parse_dimensions(self) -> _RangeBoundariesTuple | None: ...
def parse_cell(self, element) -> dict[str, Incomplete]: ...
# AnyOf[time, date, datetime, timedelta, float, int, bool, str, ArrayFormula, DataTableFormula, Translator, Text, TextBlock, CellRichText, None]
def parse_cell(self, element) -> dict[str, Any]: ...
def parse_formula(self, element): ...
def parse_column_dimensions(self, col: _HasAttrib) -> None: ...
def parse_row(self, row: _SupportsIterAndAttrib) -> tuple[int, list[dict[str, Incomplete]]]: ...
# Any: Same as parse_cell
def parse_row(self, row: _SupportsIterAndAttrib) -> tuple[int, list[dict[str, Any]]]: ...
def parse_formatting(self, element: _ChildSerialisableTreeElement) -> None: ...
def parse_sheet_protection(self, element: _SerialisableTreeElement) -> None: ...
def parse_extensions(self, element: _ChildSerialisableTreeElement) -> None: ...
Expand All @@ -100,14 +104,14 @@ class WorksheetReader:
parser: WorkSheetParser
tables: list[Incomplete]
def __init__(
self, ws, xml_source: _FileRead, shared_strings: SupportsGetItem[int, Incomplete], data_only: bool, rich_text: bool
self, ws, xml_source: _FileRead, shared_strings: SupportsGetItem[int, str], data_only: bool, rich_text: bool
) -> None: ...
def bind_cells(self) -> None: ...
def bind_formatting(self) -> None: ...
def bind_tables(self) -> None: ...
def bind_merged_cells(self) -> None: ...
def bind_hyperlinks(self) -> None: ...
def normalize_merged_cell_link(self, coord: str) -> Incomplete | None: ...
def normalize_merged_cell_link(self, coord: str) -> Cell | None: ...
def bind_col_dimensions(self) -> None: ...
def bind_row_dimensions(self) -> None: ...
def bind_properties(self) -> None: ...
Expand Down
2 changes: 1 addition & 1 deletion stubs/openpyxl/openpyxl/worksheet/_writer.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class WorksheetWriter:
def write_drawings(self) -> None: ...
def write_legacy(self) -> None: ...
def write_tables(self) -> None: ...
def get_stream(self) -> Generator[Incomplete, Incomplete, None]: ...
def get_stream(self) -> Generator[Incomplete | None, bool | None, None]: ...
def write_tail(self) -> None: ...
def write(self) -> None: ...
def close(self) -> None: ...
Expand Down
8 changes: 4 additions & 4 deletions stubs/openpyxl/openpyxl/worksheet/worksheet.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class Worksheet(_WorkbookChild):
@overload
def iter_rows(
self, min_row: int | None, max_row: int | None, min_col: int | None, max_col: int | None, values_only: bool
) -> Generator[tuple[Cell | str | float | datetime | None, ...], None, None]: ...
) -> Generator[tuple[Cell, ...], None, None] | Generator[tuple[str | float | datetime | None, ...], None, None]: ...
@overload
def iter_rows(
self,
Expand All @@ -141,7 +141,7 @@ class Worksheet(_WorkbookChild):
max_col: int | None = None,
*,
values_only: bool,
) -> Generator[tuple[Cell | str | float | datetime | None, ...], None, None]: ...
) -> Generator[tuple[Cell, ...], None, None] | Generator[tuple[str | float | datetime | None, ...], None, None]: ...
@property
def rows(self) -> Generator[tuple[Cell, ...], None, None]: ...
@property
Expand Down Expand Up @@ -172,7 +172,7 @@ class Worksheet(_WorkbookChild):
@overload
def iter_cols(
self, min_col: int | None, max_col: int | None, min_row: int | None, max_row: int | None, values_only: bool
) -> Generator[tuple[Cell | str | float | datetime | None, ...], None, None]: ...
) -> Generator[tuple[Cell, ...], None, None] | Generator[tuple[str | float | datetime | None, ...], None, None]: ...
@overload
def iter_cols(
self,
Expand All @@ -182,7 +182,7 @@ class Worksheet(_WorkbookChild):
max_row: int | None = None,
*,
values_only: bool,
) -> Generator[tuple[Cell | str | float | datetime | None, ...], None, None]: ...
) -> Generator[tuple[Cell, ...], None, None] | Generator[tuple[str | float | datetime | None, ...], None, None]: ...
@property
def columns(self) -> Generator[tuple[Cell, ...], None, None]: ...
def set_printer_settings(
Expand Down

0 comments on commit 82fd9e8

Please sign in to comment.