8000 Merge openpyxl stubs from microsoft/python-type-stubs by Avasam · Pull Request #9511 · python/typeshed · GitHub
[go: up one dir, main page]

Skip to content

Merge openpyxl stubs from microsoft/python-type-stubs #9511

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
e371358
Bring openpyxl stubs at least up to par with microsoft/python-type-stubs
Avasam Jan 10, 2023
f47d473
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Jan 11, 2023
e08d3ea
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Jan 12, 2023
9c14076
Include numpy
Avasam Jan 12, 2023
4e7fc09
Convertible Descriptors
Avasam Jan 12, 2023
8a9de85
Update after self-review
Avasam Jan 12, 2023
704399f
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Feb 8, 2023
dd5a152
Update tests
Avasam Feb 8, 2023
f11292d
Fix pytype errors
Avasam Feb 9, 2023
e3419bd
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Feb 21, 2023
7b034b2
Fixes
Avasam Feb 21, 2023
674f8ff
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Feb 23, 2023
093b061
PR comments
Avasam Feb 23, 2023
ba82470
quick CI fixes
Avasam Feb 23, 2023
9e63d21
failed at version checking
Avasam Feb 23, 2023
d1e618e
Apply suggestions from code review
Avasam Feb 28, 2023
6d6d1ce
Add alias _UnderlineType and update Self
Avasam Feb 28, 2023
567a1a8
Merge branch 'openpyxl-from-microsoft-python-type-stubs' of https://g…
Avasam Feb 28, 2023
12789fe
Post-merge fixes
Avasam Feb 28, 2023
bfb6c60
Make stubuploader tests pass
Avasam Feb 28, 2023
2a98afc
Merge branch 'main' into openpyxl-from-microsoft-python-type-stubs
AlexWaygood Mar 16, 2023
f5df850
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 16, 2023
028ac1c
Apply suggestions from code review
AlexWaygood Mar 16, 2023
6bdc7df
Update stubs/openpyxl/openpyxl/reader/workbook.pyi
AlexWaygood Mar 16, 2023
e5e4eb3
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Mar 22, 2023
7b9ccae
Merge branch 'main' into openpyxl-from-microsoft-python-type-stubs
srittau Mar 24, 2023
c7c24e8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 24, 2023
368a500
Merge branch 'openpyxl-from-microsoft-python-type-stubs' of https://g…
Avasam Mar 31, 2023
ed09fc2
Run stubdefaulter
Avasam Mar 31, 2023
b5fd48c
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Mar 31, 2023
feef334
Use new type aliases for params
Avasam May 10, 2023
bc66516
Type MetaSerialisable dunders
Avasam May 10, 2023
4bfc8fb
Merge branch 'Type-MetaSerialisable-dunders' of https://github.com/Av…
Avasam May 10, 2023
4a050d9
regroup __init__ in stubtest_allowlist
Avasam May 10, 2023
93c9bfc
.
Avasam May 10, 2023
a1f40c6
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam May 20, 2023
2557483
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Jun 12, 2023
ff8e704
Type openpyxl incomplete dunders
Avasam Jun 12, 2023
ac138f8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 12, 2023
031592c
Remove redundant suppressions
Avasam Jun 12, 2023
d856a33
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Jun 13, 2023
328001b
Merge branch 'openpyxl-incomplete-dunders' of https://github.com/Avas…
Avasam Jun 13, 2023
82d17a6
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Jun 15, 2023
c127da3
Merge branch 'openpyxl-incomplete-dunders' of https://github.com/Avas…
Avasam Jun 15, 2023
6331d8a
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Jul 23, 2023
ce181aa
_SerialisableTreeElement
Avasam Jul 23, 2023
a4fff41
openpyxl: Class properties set explicitely as another class'
Avasam Aug 9, 2023
7b2180d
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Aug 11, 2023
dba0b8d
Merge branch 'openpyxl-Class-properties-set-explicitely' of https://g…
Avasam Aug 11, 2023
aac6860
Complete openpyxl title type annotations
Avasam Aug 11, 2023
79bd5fe
Merge branch 'openpyxl-title' of https://github.com/Avasam/typeshed i…
Avasam Aug 12, 2023
0ba3633
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Aug 15, 2023
50a27a8
Fixes post merge
Avasam Aug 18, 2023
8c43a40
Complete `from_tree`
Avasam Aug 18, 2023
8000
f5cb6fe
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Aug 21, 2023
491efaf
Serialisable.from_tree improvement to avoid override issues
Avasam Aug 21, 2023
94c8b66
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Sep 12, 2023
a2e8d15
Type usages of PIL and zipfile
Avasam Sep 12, 2023
f08c6f1
Update stubtest_allowlist
Avasam Sep 12, 2023
29c9218
Update `get_rel`
Avasam Sep 12, 2023
c32f3e2
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Sep 19, 2023
a27c72f
Merge branch 'openpyxl-external-types' of https://github.com/Avasam/t…
Avasam Sep 19, 2023
5a284d6
Extract PIL and zipfile to #10706
Avasam Sep 19, 2023
200c096
datetime and _FileRead changes and fixes
Avasam Sep 19, 2023
9eb96b8
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Oct 13, 2023
d0793fc
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Oct 16, 2023
b957b79
Revert some import changes to reduce changes
Avasam Oct 16, 2023
ae8101c
Generator send actually unknown
Avasam Oct 16, 2023
6f408a6
avoid backref
Avasam Oct 16, 2023
11446be
tagname stays classvar
Avasam Oct 16, 2023
1f66b3f
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Nov 1, 2023
2fbb0e3
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Nov 2, 2023
5fc62cc
non-complex extraction from 9511
Avasam Dec 1, 2023
cc96eb4
Fix CI failures
Avasam Dec 1, 2023
169ea20
create_sheet return type
Avasam Dec 1, 2023
c0521d1
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Dec 1, 2023
d491dd8
Merge branch 'main' of https://github.com/python/typeshed into non-co…
Avasam Dec 1, 2023
a74c7ef
Post-merge fix missing Element
Avasam Dec 1, 2023
c272267
Merge branch 'non-complex-extraction-from-9511' of https://github.com…
Avasam Dec 1, 2023
17ff8a0
.
Avasam Dec 1, 2023
fd5a9a9
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Dec 4, 2023
333054d
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Dec 6, 2023
b35695d
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Mar 6, 2024
3b0034b
Update stubs/openpyxl/openpyxl/worksheet/_reader.pyi
Avasam Mar 6, 2024
6290b35
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Mar 11, 2024
08e4e91
Merge branch 'openpyxl-from-microsoft-python-type-stubs' of https://g…
Avasam Mar 11, 2024
a9021fc
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Mar 13, 2024
2bf8906
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Apr 1, 2024
8db96b3
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Apr 8, 2024
e2f2720
Merge branch 'main' into openpyxl-from-microsoft-python-type-stubs
Avasam Aug 18, 2024
2979638
Merge branch 'main' into openpyxl-from-microsoft-python-type-stubs
Avasam Sep 23, 2024
9cd6ffe
openpyxl: `Cell | MergedCell` annotations
Avasam Nov 25, 2024
82b5fcc
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 25, 2024
e0d6119
lint fixes
Avasam Nov 25, 2024
f17d61c
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Nov 25, 2024
0b0b501
Rename _Cell to _CellOrMergedCell
10000 Avasam Nov 25, 2024
1a6d68e
Merge branch 'openpyxl-Cell-or-MergedCell-annotations' of https://git…
Avasam Nov 25, 2024
3fe91a6
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Nov 25, 2024
0542fd2
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam May 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stubs/openpyxl/openpyxl/cell/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ _CellValue: TypeAlias = ( # noqa: Y047 # Used in other modules
)
_AnyCellValue: TypeAlias = Any # Any of _CellValue # noqa: Y047 # Used in other modules

_CellOrMergedCell: TypeAlias = Cell | MergedCell
_CellOrMergedCell: TypeAlias = Cell | MergedCell # noqa: Y047 # Used in other modules
6 changes: 4 additions & 2 deletions stubs/openpyxl/openpyxl/cell/_writer.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from _typeshed import Incomplete, Unused

def etree_write_cell(xf, worksheet: Unused, cell, styled: Incomplete | None = None) -> None: ...
def lxml_write_cell(xf, worksheet: Unused, cell, styled: bool = False) -> None: ...
from openpyxl.cell import _CellOrMergedCell

def etree_write_cell(xf, worksheet: Unused, cell: _CellOrMergedCell, styled: Incomplete | None = None) -> None: ...
def lxml_write_cell(xf, worksheet: Unused, cell: _CellOrMergedCell, styled: bool = False) -> None: ...

write_cell = lxml_write_cell
write_cell = etree_write_cell
4 changes: 2 additions & 2 deletions stubs/openpyxl/openpyxl/cell/cell.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ from datetime import datetime
from re import Pattern
from typing import Final, Literal, overload

from openpyxl.cell import _CellValue, _TimeTypes
from openpyxl.cell import _CellOrMergedCell, _CellValue, _TimeTypes
from openpyxl.comments.comments import Comment
from openpyxl.compat.numbers import NUMERIC_TYPES as NUMERIC_TYPES # cell numeric types
from openpyxl.styles.cell_style import StyleArray
Expand Down Expand Up @@ -75,7 +75,7 @@ class Cell(StyleableObject):
def hyperlink(self, val: Hyperlink | str | None) -> None: ...
@property
def is_date(self) -> bool: ...
def offset(self, row: int = 0, column: int = 0) -> Cell: ...
def offset(self, row: int = 0, column: int = 0) -> _CellOrMergedCell: ...
@property
def comment(self) -> Comment | None: ...
@comment.setter
Expand Down
3 changes: 2 additions & 1 deletion stubs/openpyxl/openpyxl/comments/comment_sheet.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ from collections.abc import Generator
from typing import ClassVar, Literal, overload
from typing_extensions import TypeAlias

from openpyxl.cell import _CellOrMergedCell
from openpyxl.cell.text import Text
from openpyxl.comments.author import AuthorList
from openpyxl.comments.comments import Comment
Expand Down Expand Up @@ -101,7 +102,7 @@ class CommentRecord(Serialisable):
width: int = 144,
) -> None: ...
@classmethod
def from_cell(cls, cell): ...
def from_cell(cls, cell: _CellOrMergedCell): ...
@property
def content(self) -> str: ...

Expand Down
19 changes: 5 additions & 14 deletions stubs/openpyxl/openpyxl/worksheet/_read_only.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from _typeshed import SupportsGetItem
from collections.abc import Generator, Iterator
from typing import Any, overload
from collections.abc import Generator

from openpyxl import _VisibilityType
from openpyxl.cell import _CellValue
from openpyxl.cell.cell import Cell
from openpyxl.cell import _CellOrMergedCell, _CellValue
from openpyxl.utils.cell import _RangeBoundariesTuple
from openpyxl.workbook.workbook import Workbook
from openpyxl.worksheet.worksheet import Worksheet
Expand All @@ -21,16 +19,9 @@ class ReadOnlyWorksheet:
# Same as Worksheet.rows
# https://github.com/python/mypy/issues/6700
@property
def rows(self) -> Generator[tuple[Cell, ...], None, None]: ...
# From Worksheet.__getitem__
@overload
def __getitem__(self, key: int) -> tuple[Cell, ...]: ...
@overload
def __getitem__(self, key: slice) -> tuple[Any, ...]: ... # tuple[AnyOf[Cell, tuple[Cell, ...]]]
@overload
def __getitem__(self, key: str) -> Any: ... # AnyOf[Cell, tuple[Cell, ...], tuple[tuple[Cell, ...], ...]]
# From Worksheet.__iter__
def __iter__(self) -> Iterator[tuple[Cell, ...]]: ...
def rows(self) -> Generator[tuple[_CellOrMergedCell, ...], None, None]: ...
__getitem__ = Worksheet.__getitem__
__iter__ = Worksheet.__iter__
parent: Workbook
title: str
sheet_state: _VisibilityType
Expand Down
5 changes: 2 additions & 3 deletions stubs/openpyxl/openpyxl/worksheet/_reader.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ from datetime import datetime
from typing import Final
from xml.etree.ElementTree import _FileRead

from openpyxl.cell import _AnyCellValue
from openpyxl.cell.cell import Cell
from openpyxl.cell import _AnyCellValue, _CellOrMergedCell
from openpyxl.cell.rich_text import CellRichText
from openpyxl.descriptors.serialisable import _ChildSerialisableTreeElement, _SerialisableTreeElement
from openpyxl.formula.translate import Translator
Expand Down Expand Up @@ -111,7 +110,7 @@ class WorksheetReader:
def bind_tables(self) -> None: ...
def bind_merged_cells(self) -> None: ...
def bind_hyperlinks(self) -> None: ...
def normalize_merged_cell_link(self, coord: str) -> Cell | None: ...
def normalize_merged_cell_link(self, coord: str) -> _CellOrMergedCell | None: ...
def bind_col_dimensions(self) -> None: ...
def bind_row_dimensions(self) -> None: ...
def bind_properties(self) -> None: ...
Expand Down
8 changes: 4 additions & 4 deletions stubs/openpyxl/openpyxl/worksheet/_writer.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from _typeshed import Incomplete, ReadableBuffer, StrPath, Unused
from collections.abc import Generator
from collections.abc import Generator, Iterable
from typing import Protocol
from typing_extensions import TypeAlias

from openpyxl.cell.cell import Cell
from openpyxl.cell import _CellOrMergedCell
from openpyxl.worksheet._write_only import WriteOnlyWorksheet
from openpyxl.worksheet.worksheet import Worksheet

Expand Down Expand Up @@ -31,9 +31,9 @@ class WorksheetWriter:
def write_views(self) -> None: ...
def write_cols(self) -> None: ...
def write_top(self) -> None: ...
def rows(self) -> list[tuple[int, list[Cell]]]: ...
def rows(self) -> list[tuple[int, list[_CellOrMergedCell]]]: ...
def write_rows(self) -> None: ...
def write_row(self, xf, row, row_idx) -> None: ...
def write_row(self, xf, row: Iterable[_CellOrMergedCell], row_idx) -> None: ...
def write_protection(self) -> None: ...
def write_scenarios(self) -> None: ...
def write_filter(self) -> None: ...
Expand Down
3 changes: 2 additions & 1 deletion stubs/openpyxl/openpyxl/worksheet/merge.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from _typeshed import Incomplete, Unused
from typing import ClassVar

from openpyxl.cell import _CellOrMergedCell
from openpyxl.descriptors.serialisable import Serialisable
from openpyxl.worksheet.worksheet import Worksheet

Expand Down Expand Up @@ -29,7 +30,7 @@ class MergeCells(Serialisable):

class MergedCellRange(CellRange):
ws: Worksheet
start_cell: Incomplete
start_cell: _CellOrMergedCell
def __init__(self, worksheet: Worksheet, coord) -> None: ...
def format(self) -> None: ...
def __contains__(self, coord: str) -> bool: ...
Expand Down
24 changes: 13 additions & 11 deletions stubs/openpyxl/openpyxl/worksheet/worksheet.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Worksheet(_WorkbookChild):
ORIENTATION_PORTRAIT: Final = "portrait"
ORIENTATION_LANDSCAPE: Final = "landscape"

_cells: dict[tuple[int, int], _CellOrMergedCell]
_cells: dict[tuple[int, int], _CellOrMergedCell] # private but very useful to understand typing
row_dimensions: DimensionHolder[int, RowDimension]
column_dimensions: DimensionHolder[str, ColumnDimension]
row_breaks: RowBreak
Expand Down Expand Up @@ -85,19 +85,21 @@ class Worksheet(_WorkbookChild):
@property
def freeze_panes(self) -> str | None: ...
@freeze_panes.setter
def freeze_panes(self, topLeftCell: str | Cell | None = ...) -> None: ...
def cell(self, row: int, column: int, value: _CellValue | None = None) -> Cell: ...
def freeze_panes(self, topLeftCell: str | Cell | None = None) -> None: ...
def cell(self, row: int, column: int, value: _CellValue | None = None) -> _CellOrMergedCell: ...
# An int is necessarily a row selection
@overload
def __getitem__(self, key: int) -> tuple[Cell, ...]: ...
def __getitem__(self, key: int) -> tuple[_CellOrMergedCell, ...]: ...
# A slice is necessarily a row or rows, even if targetting a single cell
@overload
def __getitem__(self, key: slice) -> tuple[Any, ...]: ... # tuple[AnyOf[Cell, tuple[Cell, ...]]]
def __getitem__(self, key: slice) -> tuple[Any, ...]: ... # tuple[AnyOf[_CellOrMergedCell, tuple[_CellOrMergedCell, ...]]]
# 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 __getitem__(
self, key: str
) -> Any: ... # AnyOf[_CellOrMergedCell, tuple[_CellOrMergedCell, ...], tuple[tuple[_CellOrMergedCell, ...], ...]]
def __setitem__(self, key: str, value: _CellValue) -> None: ...
def __iter__(self) -> Iterator[tuple[Cell, ...]]: ...
def __iter__(self) -> Iterator[tuple[_CellOrMergedCell, ...]]: ...
def __delitem__(self, key: str) -> None: ...
@property
def min_row(self) -> int: ...
Expand Down Expand Up @@ -148,7 +150,7 @@ class Worksheet(_WorkbookChild):
values_only: bool,
) -> Generator[tuple[_CellOrMergedCell, ...], None, None] | Generator[tuple[_CellValue, ...], None, None]: ...
@property
def rows(self) -> Generator[tuple[Cell, ...], None, None]: ...
def rows(self) -> Generator[tuple[_CellOrMergedCell, ...], None, None]: ...
@property
def values(self) -> Generator[tuple[_CellValue | None, ...]]: ...
@overload
Expand Down Expand Up @@ -241,10 +243,10 @@ class Worksheet(_WorkbookChild):
def append(
self,
iterable: (
list[_CellValue | Cell]
| tuple[_CellValue | Cell, ...]
list[Any] # lists are invariant, but any subtype or union will do
| tuple[_CellOrMergedCell | _CellValue, ...]
| range
| GeneratorType[_CellValue | Cell, object, object]
| GeneratorType[_CellOrMergedCell | _CellValue, object, object]
| dict[int | str, _CellValue]
),
) -> None: ...
Expand Down
0