diff --git a/stubs/openpyxl/openpyxl/cell/__init__.pyi b/stubs/openpyxl/openpyxl/cell/__init__.pyi index cc5d82bfe804..92212f351ebe 100644 --- a/stubs/openpyxl/openpyxl/cell/__init__.pyi +++ b/stubs/openpyxl/openpyxl/cell/__init__.pyi @@ -1,2 +1,22 @@ +from datetime import date, datetime, time, timedelta +from decimal import Decimal +from typing_extensions import TypeAlias + +from openpyxl.cell.rich_text import CellRichText +from openpyxl.worksheet.formula import ArrayFormula, DataTableFormula + from .cell import Cell as Cell, MergedCell as MergedCell, WriteOnlyCell as WriteOnlyCell from .read_only import ReadOnlyCell as ReadOnlyCell + +_TimeTypes: TypeAlias = datetime | date | time | timedelta +_CellValue: TypeAlias = ( # noqa: Y047 # Used in other modules + # if numpy is installed also numpy bool and number types + bool + | float + | Decimal + | str + | CellRichText + | _TimeTypes + | DataTableFormula + | ArrayFormula +) diff --git a/stubs/openpyxl/openpyxl/cell/cell.pyi b/stubs/openpyxl/openpyxl/cell/cell.pyi index 1f4ee9568367..fd14bfda844c 100644 --- a/stubs/openpyxl/openpyxl/cell/cell.pyi +++ b/stubs/openpyxl/openpyxl/cell/cell.pyi @@ -1,22 +1,16 @@ -from datetime import date, datetime, time, timedelta -from decimal import Decimal +from _typeshed import ReadableBuffer +from datetime import datetime from re import Pattern from typing import overload -from typing_extensions import Final, TypeAlias +from typing_extensions import Final -from openpyxl.cell.rich_text import CellRichText +from openpyxl.cell import _CellValue, _TimeTypes from openpyxl.comments.comments import Comment from openpyxl.styles.cell_style import StyleArray from openpyxl.styles.styleable import StyleableObject -from openpyxl.worksheet.formula import ArrayFormula, DataTableFormula from openpyxl.worksheet.hyperlink import Hyperlink from openpyxl.worksheet.worksheet import Worksheet -_TimeTypes: TypeAlias = datetime | date | time | timedelta -_CellValue: TypeAlias = ( # if numpy is installed also numpy bool and number types - bool | float | Decimal | str | CellRichText | _TimeTypes | DataTableFormula | ArrayFormula -) - __docformat__: Final = "restructuredtext en" TIME_TYPES: Final[tuple[type, ...]] TIME_FORMATS: Final[dict[type[_TimeTypes], str]] @@ -65,14 +59,14 @@ class Cell(StyleableObject): @overload def check_string(self, value: None) -> None: ... @overload - def check_string(self, value: str | bytes) -> str: ... + def check_string(self, value: str | ReadableBuffer) -> str: ... def check_error(self, value: object) -> str: ... @property - def value(self) -> _CellValue: ... + def value(self) -> _CellValue | None: ... @value.setter def value(self, value: _CellValue | bytes | None) -> None: ... @property - def internal_value(self) -> _CellValue: ... + def internal_value(self) -> _CellValue | None: ... @property def hyperlink(self) -> Hyperlink | None: ... @hyperlink.setter @@ -92,6 +86,7 @@ class MergedCell(StyleableObject): row: int column: int def __init__(self, worksheet: Worksheet, row: int | None = None, column: int | None = None) -> None: ... + # Same as Cell.coordinate @property def coordinate(self) -> str: ... value: str | float | int | datetime | None diff --git a/stubs/openpyxl/openpyxl/cell/read_only.pyi b/stubs/openpyxl/openpyxl/cell/read_only.pyi index 71e54e185bf9..b465734c9ec5 100644 --- a/stubs/openpyxl/openpyxl/cell/read_only.pyi +++ b/stubs/openpyxl/openpyxl/cell/read_only.pyi @@ -1,6 +1,14 @@ from _typeshed import Incomplete from typing_extensions import Final +from openpyxl.cell import _CellValue +from openpyxl.styles.alignment import Alignment +from openpyxl.styles.borders import Border +from openpyxl.styles.cell_style import StyleArray +from openpyxl.styles.fills import Fill +from openpyxl.styles.fonts import Font +from openpyxl.styles.protection import Protection + class ReadOnlyCell: parent: Incomplete row: Incomplete @@ -9,35 +17,38 @@ class ReadOnlyCell: def __init__(self, sheet, row, column, value, data_type: str = "n", style_id: int = 0) -> None: ... def __eq__(self, other): ... def __ne__(self, other): ... - # defined twice in the implementation + # Same as Cell.coordinate + # Defined twice in the implementation @property - def coordinate(self): ... + def coordinate(self) -> str: ... + # Same as Cell.column_letter @property - def column_letter(self): ... + def column_letter(self) -> str: ... @property - def style_array(self): ... + def style_array(self) -> StyleArray: ... @property - def has_style(self): ... + def has_style(self) -> bool: ... @property - def number_format(self): ... + def number_format(self) -> str: ... @property - def font(self): ... + def font(self) -> Font: ... @property - def fill(self): ... + def fill(self) -> Fill: ... @property - def border(self): ... + def border(self) -> Border: ... @property - def alignment(self): ... + def alignment(self) -> Alignment: ... @property - def protection(self): ... + def protection(self) -> Protection: ... + # Same as Cell.is_date @property - def is_date(self): ... + def is_date(self) -> bool: ... @property - def internal_value(self): ... + def internal_value(self) -> _CellValue | None: ... @property - def value(self): ... + def value(self) -> _CellValue | None: ... @value.setter - def value(self, value) -> None: ... + def value(self, value: None) -> None: ... class EmptyCell: value: Incomplete diff --git a/stubs/openpyxl/openpyxl/cell/text.pyi b/stubs/openpyxl/openpyxl/cell/text.pyi index 24a59d2101b2..56ee76b30e62 100644 --- a/stubs/openpyxl/openpyxl/cell/text.pyi +++ b/stubs/openpyxl/openpyxl/cell/text.pyi @@ -95,4 +95,4 @@ class Text(Serialisable): __elements__: ClassVar[tuple[str, ...]] def __init__(self, t: object = None, r=(), rPh=(), phoneticPr: _PhoneticProperties | None = None) -> None: ... @property - def content(self): ... + def content(self) -> str: ... diff --git a/stubs/openpyxl/openpyxl/chart/_chart.pyi b/stubs/openpyxl/openpyxl/chart/_chart.pyi index d59f5e108d5b..816919bdd357 100644 --- a/stubs/openpyxl/openpyxl/chart/_chart.pyi +++ b/stubs/openpyxl/openpyxl/chart/_chart.pyi @@ -46,4 +46,4 @@ class ChartBase(Serialisable): def add_data(self, data, from_rows: bool = False, titles_from_data: bool = False) -> None: ... def append(self, value) -> None: ... @property - def path(self): ... + def path(self) -> str: ... diff --git a/stubs/openpyxl/openpyxl/chart/reference.pyi b/stubs/openpyxl/openpyxl/chart/reference.pyi index 72d0a106f803..71eaf66b6dfc 100644 --- a/stubs/openpyxl/openpyxl/chart/reference.pyi +++ b/stubs/openpyxl/openpyxl/chart/reference.pyi @@ -41,9 +41,9 @@ class Reference(Strict): def __len__(self) -> int: ... def __eq__(self, other): ... @property - def rows(self) -> Generator[Incomplete, None, None]: ... + def rows(self) -> Generator[Reference, None, None]: ... @property - def cols(self) -> Generator[Incomplete, None, None]: ... + def cols(self) -> Generator[Reference, None, None]: ... def pop(self): ... @property - def sheetname(self): ... + def sheetname(self) -> str: ... diff --git a/stubs/openpyxl/openpyxl/comments/comment_sheet.pyi b/stubs/openpyxl/openpyxl/comments/comment_sheet.pyi index 4d10664d0c4f..f15829346b6d 100644 --- a/stubs/openpyxl/openpyxl/comments/comment_sheet.pyi +++ b/stubs/openpyxl/openpyxl/comments/comment_sheet.pyi @@ -5,6 +5,7 @@ from typing_extensions import Literal, TypeAlias from openpyxl.cell.text import Text from openpyxl.comments.author import AuthorList +from openpyxl.comments.comments import Comment from openpyxl.descriptors.base import Bool, Integer, Set, String, Typed, _ConvertibleToBool, _ConvertibleToInt from openpyxl.descriptors.excel import ExtensionList from openpyxl.descriptors.serialisable import Serialisable @@ -101,7 +102,7 @@ class CommentRecord(Serialisable): @classmethod def from_cell(cls, cell): ... @property - def content(self): ... + def content(self) -> str: ... class CommentSheet(Serialisable): tagname: ClassVar[str] @@ -113,9 +114,9 @@ class CommentSheet(Serialisable): def __init__(self, authors: AuthorList, commentList: Incomplete | None = None, extLst: Unused = None) -> None: ... def to_tree(self): ... @property - def comments(self) -> Generator[Incomplete, None, None]: ... + def comments(self) -> Generator[tuple[str, Comment], None, None]: ... @classmethod def from_comments(cls, comments): ... def write_shapes(self, vml: Incomplete | None = None): ... @property - def path(self): ... + def path(self) -> str: ... diff --git a/stubs/openpyxl/openpyxl/comments/comments.pyi b/stubs/openpyxl/openpyxl/comments/comments.pyi index e529f78da6d8..a735081bfd65 100644 --- a/stubs/openpyxl/openpyxl/comments/comments.pyi +++ b/stubs/openpyxl/openpyxl/comments/comments.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete +from typing import Any class Comment: content: Incomplete @@ -7,12 +8,12 @@ class Comment: width: Incomplete def __init__(self, text, author, height: int = 79, width: int = 144) -> None: ... @property - def parent(self): ... + def parent(self) -> Any: ... # AnyOf[Cell, MergedCell, ReadOnlyCell] def __eq__(self, other): ... def __copy__(self): ... def bind(self, cell) -> None: ... def unbind(self) -> None: ... @property - def text(self): ... + def text(self) -> str: ... @text.setter - def text(self, value) -> None: ... + def text(self, value: str) -> None: ... diff --git a/stubs/openpyxl/openpyxl/drawing/drawing.pyi b/stubs/openpyxl/openpyxl/drawing/drawing.pyi index 0637334dae93..2dddc130021e 100644 --- a/stubs/openpyxl/openpyxl/drawing/drawing.pyi +++ b/stubs/openpyxl/openpyxl/drawing/drawing.pyi @@ -1,5 +1,7 @@ from _typeshed import Incomplete +from .spreadsheet_drawing import AbsoluteAnchor, OneCellAnchor + class Drawing: count: int name: str @@ -14,13 +16,13 @@ class Drawing: anchorrow: int def __init__(self) -> None: ... @property - def width(self): ... + def width(self) -> int: ... @width.setter - def width(self, w) -> None: ... + def width(self, w: int) -> None: ... @property - def height(self): ... + def height(self) -> int: ... @height.setter - def height(self, h) -> None: ... + def height(self, h: int) -> None: ... def set_dimension(self, w: int = 0, h: int = 0) -> None: ... @property - def anchor(self): ... + def anchor(self) -> AbsoluteAnchor | OneCellAnchor: ... diff --git a/stubs/openpyxl/openpyxl/drawing/image.pyi b/stubs/openpyxl/openpyxl/drawing/image.pyi index 3864d30df85b..b275596fd009 100644 --- a/stubs/openpyxl/openpyxl/drawing/image.pyi +++ b/stubs/openpyxl/openpyxl/drawing/image.pyi @@ -6,4 +6,4 @@ class Image: format: Incomplete def __init__(self, img) -> None: ... @property - def path(self): ... + def path(self) -> str: ... diff --git a/stubs/openpyxl/openpyxl/drawing/spreadsheet_drawing.pyi b/stubs/openpyxl/openpyxl/drawing/spreadsheet_drawing.pyi index cb0f7762af76..d516ce6a0260 100644 --- a/stubs/openpyxl/openpyxl/drawing/spreadsheet_drawing.pyi +++ b/stubs/openpyxl/openpyxl/drawing/spreadsheet_drawing.pyi @@ -118,4 +118,4 @@ class SpreadsheetDrawing(Serialisable): def __hash__(self) -> int: ... def __bool__(self) -> bool: ... @property - def path(self): ... + def path(self) -> str: ... diff --git a/stubs/openpyxl/openpyxl/formula/tokenizer.pyi b/stubs/openpyxl/openpyxl/formula/tokenizer.pyi index 6b7d97431fd7..acf53bcb91f0 100644 --- a/stubs/openpyxl/openpyxl/formula/tokenizer.pyi +++ b/stubs/openpyxl/openpyxl/formula/tokenizer.pyi @@ -1,6 +1,13 @@ from _typeshed import Incomplete from re import Pattern -from typing_extensions import Final +from typing_extensions import Final, Literal, TypeAlias + +_TokenTypesNotOperand: TypeAlias = Literal[ + "LITERAL", "FUNC", "ARRAY", "PAREN", "SEP", "OPERATOR-PREFIX", "OPERATOR-INFIX", "OPERATOR-POSTFIX", "WHITE-SPACE" +] +_TokenTypes: TypeAlias = Literal["OPERAND", _TokenTypesNotOperand] +_TokenOperandSubtypes: TypeAlias = Literal["TEXT", "NUMBER", "LOGICAL", "ERROR", "RANGE"] +_TokenSubtypes: TypeAlias = Literal["", _TokenOperandSubtypes, "OPEN", "CLOSE", "ARG", "ROW"] class TokenizerError(Exception): ... @@ -33,9 +40,9 @@ class Token: OP_POST: Final = "OPERATOR-POSTFIX" WSPACE: Final = "WHITE-SPACE" value: Incomplete - type: Incomplete - subtype: Incomplete - def __init__(self, value, type_, subtype: str = "") -> None: ... + type: _TokenTypes + subtype: _TokenSubtypes + def __init__(self, value, type_: _TokenTypes, subtype: _TokenSubtypes = "") -> None: ... TEXT: Final = "TEXT" NUMBER: Final = "NUMBER" LOGICAL: Final = "LOGICAL" diff --git a/stubs/openpyxl/openpyxl/packaging/interface.pyi b/stubs/openpyxl/openpyxl/packaging/interface.pyi index d000905f46b8..45a7da1114ea 100644 --- a/stubs/openpyxl/openpyxl/packaging/interface.pyi +++ b/stubs/openpyxl/openpyxl/packaging/interface.pyi @@ -1,6 +1,8 @@ -from abc import ABC, ABCMeta, abstractmethod +from abc import ABC, abstractmethod -class ISerialisableFile(ABC, metaclass=ABCMeta): +# This interface is unused. Nothing implements `id` as property either. +# IDs can be ints, strings, None, or a Descriptor returning those throughout the codebase. +class ISerialisableFile(ABC): @property @abstractmethod - def id(self): ... + def id(self) -> str | int | None: ... diff --git a/stubs/openpyxl/openpyxl/packaging/manifest.pyi b/stubs/openpyxl/openpyxl/packaging/manifest.pyi index e0b8b8430ec7..62a51a72823b 100644 --- a/stubs/openpyxl/openpyxl/packaging/manifest.pyi +++ b/stubs/openpyxl/openpyxl/packaging/manifest.pyi @@ -31,9 +31,9 @@ class Manifest(Serialisable): __elements__: ClassVar[tuple[str, ...]] def __init__(self, Default=(), Override=()) -> None: ... @property - def filenames(self): ... + def filenames(self) -> list[str]: ... @property - def extensions(self): ... + def extensions(self) -> list[tuple[str, str]]: ... def to_tree(self): ... def __contains__(self, content_type): ... def find(self, content_type): ... diff --git a/stubs/openpyxl/openpyxl/packaging/workbook.pyi b/stubs/openpyxl/openpyxl/packaging/workbook.pyi index 7f7b8117c1fd..288d93c7296a 100644 --- a/stubs/openpyxl/openpyxl/packaging/workbook.pyi +++ b/stubs/openpyxl/openpyxl/packaging/workbook.pyi @@ -101,4 +101,4 @@ class WorkbookPackage(Serialisable): ) -> None: ... def to_tree(self): ... @property - def active(self): ... + def active(self) -> int: ... diff --git a/stubs/openpyxl/openpyxl/pivot/cache.pyi b/stubs/openpyxl/openpyxl/pivot/cache.pyi index c900dbf96a31..c07c9e3a781a 100644 --- a/stubs/openpyxl/openpyxl/pivot/cache.pyi +++ b/stubs/openpyxl/openpyxl/pivot/cache.pyi @@ -101,7 +101,7 @@ class ServerFormatList(Serialisable): __attrs__: ClassVar[tuple[str, ...]] def __init__(self, count: Incomplete | None = None, serverFormat: Incomplete | None = None) -> None: ... @property - def count(self): ... + def count(self) -> int: ... class Query(Serialisable): tagname: ClassVar[str] @@ -384,7 +384,7 @@ class GroupItems(Serialisable): __attrs__: ClassVar[tuple[str, ...]] def __init__(self, count: Incomplete | None = None, m=(), n=(), b=(), e=(), s=(), d=()) -> None: ... @property - def count(self): ... + def count(self) -> int: ... class DiscretePr(Serialisable): tagname: ClassVar[str] @@ -475,7 +475,7 @@ class SharedItems(Serialisable): longText: _ConvertibleToBool | None = None, ) -> None: ... @property - def count(self): ... + def count(self) -> int: ... class CacheField(Serialisable): tagname: ClassVar[str] @@ -585,7 +585,7 @@ class Page(Serialisable): __elements__: ClassVar[tuple[str, ...]] def __init__(self, count: Incomplete | None = None, pageItem: Incomplete | None = None) -> None: ... @property - def count(self): ... + def count(self) -> int: ... class Consolidation(Serialisable): tagname: ClassVar[str] @@ -723,4 +723,4 @@ class CacheDefinition(Serialisable): ) -> None: ... def to_tree(self): ... @property - def path(self): ... + def path(self) -> str: ... diff --git a/stubs/openpyxl/openpyxl/pivot/record.pyi b/stubs/openpyxl/openpyxl/pivot/record.pyi index 7e90dac95258..234d02a97b0a 100644 --- a/stubs/openpyxl/openpyxl/pivot/record.pyi +++ b/stubs/openpyxl/openpyxl/pivot/record.pyi @@ -37,7 +37,7 @@ class RecordList(Serialisable): __attrs__: ClassVar[tuple[str, ...]] def __init__(self, count: Unused = None, r=(), extLst: ExtensionList | None = None) -> None: ... @property - def count(self): ... + def count(self) -> int: ... def to_tree(self): ... @property - def path(self): ... + def path(self) -> str: ... diff --git a/stubs/openpyxl/openpyxl/pivot/table.pyi b/stubs/openpyxl/openpyxl/pivot/table.pyi index 6f27a7a32c92..b7f89dbd128a 100644 --- a/stubs/openpyxl/openpyxl/pivot/table.pyi +++ b/stubs/openpyxl/openpyxl/pivot/table.pyi @@ -117,7 +117,7 @@ class ColHierarchiesUsage(Serialisable): __attrs__: ClassVar[tuple[str, ...]] def __init__(self, count: Incomplete | None = None, colHierarchyUsage=()) -> None: ... @property - def count(self): ... + def count(self) -> int: ... class RowHierarchiesUsage(Serialisable): tagname: ClassVar[str] @@ -126,7 +126,7 @@ class RowHierarchiesUsage(Serialisable): __attrs__: ClassVar[tuple[str, ...]] def __init__(self, count: Incomplete | None = None, rowHierarchyUsage=()) -> None: ... @property - def count(self): ... + def count(self) -> int: ... class PivotFilter(Serialisable): tagname: ClassVar[str] @@ -211,7 +211,7 @@ class MemberList(Serialisable): __elements__: ClassVar[tuple[str, ...]] def __init__(self, count: Incomplete | None = None, level: _ConvertibleToInt | None = None, member=()) -> None: ... @property - def count(self): ... + def count(self) -> int: ... class MemberProperty(Serialisable): tagname: ClassVar[str] @@ -331,7 +331,7 @@ class Reference(Serialisable): extLst: ExtensionList | None = None, ) -> None: ... @property - def count(self): ... + def count(self) -> int: ... class PivotArea(Serialisable): tagname: ClassVar[str] @@ -419,7 +419,7 @@ class ConditionalFormatList(Serialisable): def __init__(self, conditionalFormat=..., count: Incomplete | None = ...) -> None: ... def by_priority(self): ... @property - def count(self): ... + def count(self) -> int: ... def to_tree(self, tagname: str | None = None): ... # type: ignore[override] class Format(Serialisable): @@ -952,7 +952,7 @@ class TableDefinition(Serialisable): ) -> None: ... def to_tree(self): ... @property - def path(self): ... + def path(self) -> str: ... def formatted_fields(self) -> dict[Incomplete, list[Incomplete]]: ... @property def summary(self) -> str: ... diff --git a/stubs/openpyxl/openpyxl/reader/workbook.pyi b/stubs/openpyxl/openpyxl/reader/workbook.pyi index 7ef1b85e4c09..b016ceebe35c 100644 --- a/stubs/openpyxl/openpyxl/reader/workbook.pyi +++ b/stubs/openpyxl/openpyxl/reader/workbook.pyi @@ -1,6 +1,8 @@ from _typeshed import Incomplete from collections.abc import Generator +from openpyxl.packaging.relationship import RelationshipList +from openpyxl.pivot.cache import CacheDefinition from openpyxl.workbook import Workbook class WorkbookParser: @@ -11,10 +13,10 @@ class WorkbookParser: sheets: Incomplete def __init__(self, archive, workbook_part_name, keep_links: bool = True) -> None: ... @property - def rels(self): ... + def rels(self) -> RelationshipList: ... caches: Incomplete def parse(self) -> None: ... def find_sheets(self) -> Generator[Incomplete, None, None]: ... def assign_names(self) -> None: ... @property - def pivot_caches(self): ... + def pivot_caches(self) -> dict[int, CacheDefinition]: ... diff --git a/stubs/openpyxl/openpyxl/styles/cell_style.pyi b/stubs/openpyxl/openpyxl/styles/cell_style.pyi index 419464400e69..0640927d404c 100644 --- a/stubs/openpyxl/openpyxl/styles/cell_style.pyi +++ b/stubs/openpyxl/openpyxl/styles/cell_style.pyi @@ -77,9 +77,9 @@ class CellStyle(Serialisable): @classmethod def from_array(cls, style): ... @property - def applyProtection(self): ... + def applyProtection(self) -> Literal[True] | None: ... @property - def applyAlignment(self): ... + def applyAlignment(self) -> Literal[True] | None: ... class CellStyleList(Serialisable): tagname: ClassVar[str] @@ -92,5 +92,5 @@ class CellStyleList(Serialisable): __elements__: ClassVar[tuple[str, ...]] def __init__(self, count: Unused = None, xf=()) -> None: ... @property - def count(self): ... + def count(self) -> int: ... def __getitem__(self, idx): ... diff --git a/stubs/openpyxl/openpyxl/styles/colors.pyi b/stubs/openpyxl/openpyxl/styles/colors.pyi index 3b69fc27111b..a28e194a6fe0 100644 --- a/stubs/openpyxl/openpyxl/styles/colors.pyi +++ b/stubs/openpyxl/openpyxl/styles/colors.pyi @@ -36,12 +36,12 @@ class Color(Serialisable): type: Unused = "rgb", ) -> None: ... @property - def value(self): ... + def value(self) -> str | int | bool: ... @value.setter - def value(self, value) -> None: ... + def value(self, value: str | _ConvertibleToInt | _ConvertibleToBool) -> None: ... def __iter__(self): ... @property - def index(self): ... + def index(self) -> str | int | bool: ... def __add__(self, other): ... class ColorDescriptor(Typed[Color, Incomplete]): @@ -61,4 +61,4 @@ class ColorList(Serialisable): def __init__(self, indexedColors=(), mruColors=()) -> None: ... def __bool__(self) -> bool: ... @property - def index(self): ... + def index(self) -> list[str]: ... diff --git a/stubs/openpyxl/openpyxl/styles/differential.pyi b/stubs/openpyxl/openpyxl/styles/differential.pyi index 508463dd5a6e..7fac40e0f49a 100644 --- a/stubs/openpyxl/openpyxl/styles/differential.pyi +++ b/stubs/openpyxl/openpyxl/styles/differential.pyi @@ -40,4 +40,4 @@ class DifferentialStyleList(Serialisable): def __bool__(self) -> bool: ... def __getitem__(self, idx): ... @property - def count(self): ... + def count(self) -> int: ... diff --git a/stubs/openpyxl/openpyxl/styles/named_styles.pyi b/stubs/openpyxl/openpyxl/styles/named_styles.pyi index aa858f0a7ca6..10ce787942b0 100644 --- a/stubs/openpyxl/openpyxl/styles/named_styles.pyi +++ b/stubs/openpyxl/openpyxl/styles/named_styles.pyi @@ -39,7 +39,7 @@ class NamedStyle(Serialisable): def __setattr__(self, attr: str, value) -> None: ... def __iter__(self): ... @property - def xfId(self): ... + def xfId(self) -> int | None: ... def bind(self, wb) -> None: ... def as_tuple(self): ... def as_xf(self): ... @@ -47,7 +47,7 @@ class NamedStyle(Serialisable): class NamedStyleList(list[Incomplete]): @property - def names(self): ... + def names(self) -> list[str]: ... def __getitem__(self, key): ... def append(self, style) -> None: ... @@ -80,6 +80,6 @@ class _NamedCellStyleList(Serialisable): __attrs__: ClassVar[tuple[str, ...]] def __init__(self, count: Unused = None, cellStyle=()) -> None: ... @property - def count(self): ... + def count(self) -> int: ... @property - def names(self): ... + def names(self) -> NamedStyleList: ... diff --git a/stubs/openpyxl/openpyxl/styles/numbers.pyi b/stubs/openpyxl/openpyxl/styles/numbers.pyi index d23d987c884b..746ac403af0c 100644 --- a/stubs/openpyxl/openpyxl/styles/numbers.pyi +++ b/stubs/openpyxl/openpyxl/styles/numbers.pyi @@ -51,7 +51,7 @@ LOCALE_GROUP: Final = r"\[(?!hh?\]|mm?\]|ss?\])[^\]]*\]" STRIP_RE: Final[Pattern[str]] TIMEDELTA_RE: Final[Pattern[str]] -def is_date_format(fmt): ... +def is_date_format(fmt) -> bool: ... def is_timedelta_format(fmt): ... def is_datetime(fmt): ... def is_builtin(fmt): ... @@ -74,5 +74,5 @@ class NumberFormatList(Serialisable): __attrs__: ClassVar[tuple[str, ...]] def __init__(self, count: Unused = None, numFmt=()) -> None: ... @property - def count(self): ... + def count(self) -> int: ... def __getitem__(self, idx): ... diff --git a/stubs/openpyxl/openpyxl/styles/styleable.pyi b/stubs/openpyxl/openpyxl/styles/styleable.pyi index 6753a02227ec..4dfe4d235764 100644 --- a/stubs/openpyxl/openpyxl/styles/styleable.pyi +++ b/stubs/openpyxl/openpyxl/styles/styleable.pyi @@ -42,6 +42,6 @@ class StyleableObject: parent: Incomplete def __init__(self, sheet, style_array: Incomplete | None = None) -> None: ... @property - def style_id(self): ... + def style_id(self) -> int: ... @property - def has_style(self): ... + def has_style(self) -> bool: ... diff --git a/stubs/openpyxl/openpyxl/styles/stylesheet.pyi b/stubs/openpyxl/openpyxl/styles/stylesheet.pyi index b3c1465ad6ad..3d7b94d335aa 100644 --- a/stubs/openpyxl/openpyxl/styles/stylesheet.pyi +++ b/stubs/openpyxl/openpyxl/styles/stylesheet.pyi @@ -47,7 +47,7 @@ class Stylesheet(Serialisable): @classmethod def from_tree(cls, node: _ChildSerialisableTreeElement) -> Self: ... @property - def custom_formats(self): ... + def custom_formats(self) -> dict[int, str]: ... def to_tree(self, tagname: str | None = None, idx: Incomplete | None = None, namespace: str | None = None): ... def apply_stylesheet(archive, wb): ... diff --git a/stubs/openpyxl/openpyxl/styles/table.pyi b/stubs/openpyxl/openpyxl/styles/table.pyi index e9853be0fcd3..48875a293ac6 100644 --- a/stubs/openpyxl/openpyxl/styles/table.pyi +++ b/stubs/openpyxl/openpyxl/styles/table.pyi @@ -77,4 +77,4 @@ class TableStyleList(Serialisable): tableStyle=(), ) -> None: ... @property - def count(self): ... + def count(self) -> int: ... diff --git a/stubs/openpyxl/openpyxl/utils/protection.pyi b/stubs/openpyxl/openpyxl/utils/protection.pyi index f2b3f73e367c..4bcddbe2b676 100644 --- a/stubs/openpyxl/openpyxl/utils/protection.pyi +++ b/stubs/openpyxl/openpyxl/utils/protection.pyi @@ -1 +1 @@ -def hash_password(plaintext_password: str = ""): ... +def hash_password(plaintext_password: str = "") -> str: ... diff --git a/stubs/openpyxl/openpyxl/workbook/child.pyi b/stubs/openpyxl/openpyxl/workbook/child.pyi index 827361215c48..678dcbb1a264 100644 --- a/stubs/openpyxl/openpyxl/workbook/child.pyi +++ b/stubs/openpyxl/openpyxl/workbook/child.pyi @@ -3,6 +3,8 @@ from re import Pattern from typing_extensions import Final from openpyxl import _Decodable +from openpyxl.workbook.workbook import Workbook +from openpyxl.worksheet.header_footer import HeaderFooterItem INVALID_TITLE_REGEX: Final[Pattern[str]] @@ -10,38 +12,38 @@ def avoid_duplicate_name(names, value): ... class _WorkbookChild: HeaderFooter: Incomplete - def __init__(self, parent: Incomplete | None = None, title: str | _Decodable | None = None) -> None: ... + def __init__(self, parent: Workbook | None = None, title: str | _Decodable | None = None) -> None: ... @property - def parent(self): ... + def parent(self) -> Workbook | None: ... @property - def encoding(self): ... + def encoding(self) -> str: ... # Will error without a parent. @property def title(self) -> str: ... @title.setter def title(self, value: str | _Decodable) -> None: ... @property - def oddHeader(self): ... + def oddHeader(self) -> HeaderFooterItem | None: ... @oddHeader.setter - def oddHeader(self, value) -> None: ... + def oddHeader(self, value: HeaderFooterItem | None) -> None: ... @property - def oddFooter(self): ... + def oddFooter(self) -> HeaderFooterItem | None: ... @oddFooter.setter - def oddFooter(self, value) -> None: ... + def oddFooter(self, value: HeaderFooterItem | None) -> None: ... @property - def evenHeader(self): ... + def evenHeader(self) -> HeaderFooterItem | None: ... @evenHeader.setter - def evenHeader(self, value) -> None: ... + def evenHeader(self, value: HeaderFooterItem | None) -> None: ... @property - def evenFooter(self): ... + def evenFooter(self) -> HeaderFooterItem | None: ... @evenFooter.setter - def evenFooter(self, value) -> None: ... + def evenFooter(self, value: HeaderFooterItem | None) -> None: ... @property - def firstHeader(self): ... + def firstHeader(self) -> HeaderFooterItem | None: ... @firstHeader.setter - def firstHeader(self, value) -> None: ... + def firstHeader(self, value: HeaderFooterItem | None) -> None: ... @property - def firstFooter(self): ... + def firstFooter(self) -> HeaderFooterItem | None: ... @firstFooter.setter - def firstFooter(self, value) -> None: ... + def firstFooter(self, value: HeaderFooterItem | None) -> None: ... @property - def path(self): ... + def path(self) -> str: ... diff --git a/stubs/openpyxl/openpyxl/workbook/defined_name.pyi b/stubs/openpyxl/openpyxl/workbook/defined_name.pyi index 7d3b95867fbd..a7d2e4eb8c03 100644 --- a/stubs/openpyxl/openpyxl/workbook/defined_name.pyi +++ b/stubs/openpyxl/openpyxl/workbook/defined_name.pyi @@ -8,6 +8,7 @@ from typing_extensions import Final, Literal from openpyxl.descriptors import Sequence from openpyxl.descriptors.base import Alias, Bool, Integer, String, _ConvertibleToBool, _ConvertibleToInt from openpyxl.descriptors.serialisable import Serialisable +from openpyxl.formula.tokenizer import _TokenOperandSubtypes, _TokenTypesNotOperand RESERVED: Final[frozenset[str]] RESERVED_REGEX: Final[Pattern[str]] @@ -51,13 +52,13 @@ class DefinedName(Serialisable): attr_text: Incomplete | None = None, ) -> None: ... @property - def type(self): ... + def type(self) -> _TokenTypesNotOperand | _TokenOperandSubtypes: ... @property - def destinations(self) -> Generator[Incomplete, None, None]: ... + def destinations(self) -> Generator[tuple[str, str], None, None]: ... @property - def is_reserved(self): ... + def is_reserved(self) -> str | None: ... @property - def is_external(self): ... + def is_external(self) -> bool: ... def __iter__(self): ... class DefinedNameDict(dict[str, DefinedName]): diff --git a/stubs/openpyxl/openpyxl/workbook/external_link/external.pyi b/stubs/openpyxl/openpyxl/workbook/external_link/external.pyi index fcd66e68bdff..ef1f1d578bd8 100644 --- a/stubs/openpyxl/openpyxl/workbook/external_link/external.pyi +++ b/stubs/openpyxl/openpyxl/workbook/external_link/external.pyi @@ -74,6 +74,6 @@ class ExternalLink(Serialisable): ) -> None: ... def to_tree(self): ... @property - def path(self): ... + def path(self) -> str: ... def read_external_link(archive, book_path): ... diff --git a/stubs/openpyxl/openpyxl/workbook/protection.pyi b/stubs/openpyxl/openpyxl/workbook/protection.pyi index 236dfceb6bee..21e3ceeb6042 100644 --- a/stubs/openpyxl/openpyxl/workbook/protection.pyi +++ b/stubs/openpyxl/openpyxl/workbook/protection.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete -from typing import ClassVar +from typing import ClassVar, overload from typing_extensions import Literal, Self from openpyxl.descriptors.base import Alias, Bool, Integer, String, _ConvertibleToBool, _ConvertibleToInt @@ -46,16 +46,26 @@ class WorkbookProtection(Serialisable): workbookSaltValue: Incomplete | None = None, workbookSpinCount: _ConvertibleToInt | None = None, ) -> None: ... - def set_workbook_password(self, value: str = "", already_hashed: bool = False) -> None: ... + @overload + def set_workbook_password(self, value: str = "", already_hashed: Literal[False] = False) -> None: ... + @overload + def set_workbook_password(self, value: str | None, already_hashed: Literal[True]) -> None: ... + @overload + def set_workbook_password(self, value: str | None = "", *, already_hashed: Literal[True]) -> None: ... @property - def workbookPassword(self): ... + def workbookPassword(self) -> str | None: ... @workbookPassword.setter - def workbookPassword(self, value) -> None: ... - def set_revisions_password(self, value: str = "", already_hashed: bool = False) -> None: ... + def workbookPassword(self, value: str) -> None: ... + @overload + def set_revisions_password(self, value: str = "", already_hashed: Literal[False] = False) -> None: ... + @overload + def set_revisions_password(self, value: str | None, already_hashed: Literal[True]) -> None: ... + @overload + def set_revisions_password(self, value: str | None = "", *, already_hashed: Literal[True]) -> None: ... @property - def revisionsPassword(self): ... + def revisionsPassword(self) -> str | None: ... @revisionsPassword.setter - def revisionsPassword(self, value) -> None: ... + def revisionsPassword(self, value: str) -> None: ... @classmethod def from_tree(cls, node: _SupportsIterAndAttribAndTextAndGet) -> Self: ... diff --git a/stubs/openpyxl/openpyxl/workbook/web.pyi b/stubs/openpyxl/openpyxl/workbook/web.pyi index a5c184bc4f4e..a00cd9f55cd5 100644 --- a/stubs/openpyxl/openpyxl/workbook/web.pyi +++ b/stubs/openpyxl/openpyxl/workbook/web.pyi @@ -57,7 +57,7 @@ class WebPublishObjectList(Serialisable): __elements__: ClassVar[tuple[str, ...]] def __init__(self, count: Unused = None, webPublishObject=()) -> None: ... @property - def count(self): ... + def count(self) -> int: ... class WebPublishing(Serialisable): tagname: ClassVar[str] diff --git a/stubs/openpyxl/openpyxl/worksheet/_read_only.pyi b/stubs/openpyxl/openpyxl/worksheet/_read_only.pyi index 489cae116ff8..8eba59e181a5 100644 --- a/stubs/openpyxl/openpyxl/worksheet/_read_only.pyi +++ b/stubs/openpyxl/openpyxl/worksheet/_read_only.pyi @@ -1,6 +1,9 @@ from _typeshed import Incomplete +from collections.abc import Generator from openpyxl import _VisibilityType +from openpyxl.cell import _CellValue +from openpyxl.cell.cell import Cell from openpyxl.worksheet.worksheet import Worksheet def read_dimension(source): ... @@ -10,10 +13,10 @@ class ReadOnlyWorksheet: iter_rows = Worksheet.iter_rows # Same as Worksheet.values @property - def values(self): ... + def values(self) -> Generator[tuple[_CellValue, ...], None, None]: ... # Same as Worksheet.rows @property - def rows(self): ... + def rows(self) -> Generator[tuple[Cell, ...], None, None]: ... __getitem__ = Worksheet.__getitem__ __iter__ = Worksheet.__iter__ parent: Incomplete @@ -23,10 +26,10 @@ class ReadOnlyWorksheet: def calculate_dimension(self, force: bool = False): ... def reset_dimensions(self) -> None: ... @property - def min_row(self): ... + def min_row(self) -> int: ... @property - def max_row(self): ... + def max_row(self) -> int | None: ... @property - def min_column(self): ... + def min_column(self) -> int: ... @property - def max_column(self): ... + def max_column(self) -> int | None: ... diff --git a/stubs/openpyxl/openpyxl/worksheet/_write_only.pyi b/stubs/openpyxl/openpyxl/worksheet/_write_only.pyi index 9aec689ac9ec..ffecf33377c6 100644 --- a/stubs/openpyxl/openpyxl/worksheet/_write_only.pyi +++ b/stubs/openpyxl/openpyxl/worksheet/_write_only.pyi @@ -1,7 +1,7 @@ -from _typeshed import Incomplete from collections.abc import Iterable from openpyxl import _Decodable +from openpyxl.cell.cell import Cell from openpyxl.workbook.child import _WorkbookChild from openpyxl.worksheet.table import TableList from openpyxl.worksheet.worksheet import Worksheet @@ -16,7 +16,7 @@ class WriteOnlyWorksheet(_WorkbookChild): @property def tables(self) -> TableList: ... @property - def print_titles(self) -> str | None: ... + def print_titles(self) -> str: ... @property def print_title_cols(self) -> str | None: ... @print_title_cols.setter @@ -28,15 +28,15 @@ class WriteOnlyWorksheet(_WorkbookChild): @property def freeze_panes(self) -> str | None: ... @freeze_panes.setter - def freeze_panes(self, topLeftCell: Incomplete | None = ...) -> None: ... + def freeze_panes(self, topLeftCell: str | Cell | None = ...) -> None: ... @property - def print_area(self) -> list[str]: ... + def print_area(self) -> str: ... @print_area.setter - def print_area(self, value: str | Iterable[str]) -> None: ... + def print_area(self, value: str | Iterable[str] | None) -> None: ... @property def sheet_view(self): ... def __init__(self, parent, title: str | _Decodable | None) -> None: ... @property - def closed(self): ... + def closed(self) -> bool: ... def close(self) -> None: ... def append(self, row) -> None: ... diff --git a/stubs/openpyxl/openpyxl/worksheet/cell_range.pyi b/stubs/openpyxl/openpyxl/worksheet/cell_range.pyi index 0ef744d1b373..d64a3ce6c89a 100644 --- a/stubs/openpyxl/openpyxl/worksheet/cell_range.pyi +++ b/stubs/openpyxl/openpyxl/worksheet/cell_range.pyi @@ -1,5 +1,6 @@ from _typeshed import Incomplete, Unused from collections.abc import Generator +from itertools import product from typing import overload from typing_extensions import Literal @@ -36,15 +37,15 @@ class CellRange(Serialisable): title: str | None = None, ) -> None: ... @property - def bounds(self): ... + def bounds(self) -> tuple[int, int, int, int]: ... @property - def coord(self): ... + def coord(self) -> str: ... @property - def rows(self) -> Generator[Incomplete, None, None]: ... + def rows(self) -> Generator[list[tuple[int, int]], None, None]: ... @property - def cols(self) -> Generator[Incomplete, None, None]: ... + def cols(self) -> Generator[list[tuple[int, int]], None, None]: ... @property - def cells(self): ... + def cells(self) -> product[tuple[int, int]]: ... def __copy__(self): ... def shift(self, col_shift: int = 0, row_shift: int = 0) -> None: ... def __ne__(self, other): ... @@ -65,15 +66,15 @@ class CellRange(Serialisable): def expand(self, right: int = 0, down: int = 0, left: int = 0, up: int = 0) -> None: ... def shrink(self, right: int = 0, bottom: int = 0, left: int = 0, top: int = 0) -> None: ... @property - def size(self): ... + def size(self) -> dict[str, int]: ... @property - def top(self): ... + def top(self) -> list[tuple[int, int]]: ... @property - def bottom(self): ... + def bottom(self) -> list[tuple[int, int]]: ... @property - def left(self): ... + def left(self) -> list[tuple[int, int]]: ... @property - def right(self): ... + def right(self) -> list[tuple[int, int]]: ... class MultiCellRange(Strict): ranges: Incomplete diff --git a/stubs/openpyxl/openpyxl/worksheet/datavalidation.pyi b/stubs/openpyxl/openpyxl/worksheet/datavalidation.pyi index 157a3bad2633..be101133b9b5 100644 --- a/stubs/openpyxl/openpyxl/worksheet/datavalidation.pyi +++ b/stubs/openpyxl/openpyxl/worksheet/datavalidation.pyi @@ -100,7 +100,7 @@ class DataValidationList(Serialisable): dataValidation=(), ) -> None: ... @property - def count(self): ... + def count(self) -> int: ... def __len__(self) -> int: ... def append(self, dv) -> None: ... def to_tree(self, tagname: str | None = None): ... # type: ignore[override] diff --git a/stubs/openpyxl/openpyxl/worksheet/dimensions.pyi b/stubs/openpyxl/openpyxl/worksheet/dimensions.pyi index 290a1b926ce6..b33b68b42fa3 100644 --- a/stubs/openpyxl/openpyxl/worksheet/dimensions.pyi +++ b/stubs/openpyxl/openpyxl/worksheet/dimensions.pyi @@ -148,4 +148,4 @@ class SheetDimension(Serialisable): ref: String[Literal[False]] def __init__(self, ref: str) -> None: ... @property - def boundaries(self): ... + def boundaries(self) -> tuple[int, int, int, int]: ... diff --git a/stubs/openpyxl/openpyxl/worksheet/merge.pyi b/stubs/openpyxl/openpyxl/worksheet/merge.pyi index 491fb7d10a39..8f2120a02dc2 100644 --- a/stubs/openpyxl/openpyxl/worksheet/merge.pyi +++ b/stubs/openpyxl/openpyxl/worksheet/merge.pyi @@ -9,7 +9,7 @@ class MergeCell(CellRange): tagname: ClassVar[str] # Same as CellRange.coord @property - def ref(self): ... + def ref(self) -> str: ... __attrs__: ClassVar[tuple[str, ...]] def __init__(self, ref: Incomplete | None = None) -> None: ... def __copy__(self): ... @@ -23,7 +23,7 @@ class MergeCells(Serialisable): __attrs__: ClassVar[tuple[str, ...]] def __init__(self, count: Unused = None, mergeCell=()) -> None: ... @property - def count(self): ... + def count(self) -> int: ... class MergedCellRange(CellRange): ws: Incomplete diff --git a/stubs/openpyxl/openpyxl/worksheet/page.pyi b/stubs/openpyxl/openpyxl/worksheet/page.pyi index 2538cabf076b..9fe49afa4510 100644 --- a/stubs/openpyxl/openpyxl/worksheet/page.pyi +++ b/stubs/openpyxl/openpyxl/worksheet/page.pyi @@ -4,6 +4,7 @@ from typing_extensions import Literal, Self, TypeAlias from openpyxl.descriptors.base import Bool, Float, Integer, NoneSet, _ConvertibleToBool, _ConvertibleToFloat, _ConvertibleToInt from openpyxl.descriptors.serialisable import Serialisable, _ChildSerialisableTreeElement +from openpyxl.worksheet.properties import PageSetupProperties _PrintPageSetupOrientation: TypeAlias = Literal["default", "portrait", "landscape"] _PrintPageSetupPageOrder: TypeAlias = Literal["downThenOver", "overThenDown"] @@ -56,15 +57,15 @@ class PrintPageSetup(Serialisable): ) -> None: ... def __bool__(self) -> bool: ... @property - def sheet_properties(self): ... + def sheet_properties(self) -> PageSetupProperties | None: ... @property - def fitToPage(self): ... + def fitToPage(self) -> bool | None: ... @fitToPage.setter - def fitToPage(self, value) -> None: ... + def fitToPage(self, value: _ConvertibleToBool | None) -> None: ... @property - def autoPageBreaks(self): ... + def autoPageBreaks(self) -> bool | None: ... @autoPageBreaks.setter - def autoPageBreaks(self, value) -> None: ... + def autoPageBreaks(self, value: _ConvertibleToBool | None) -> None: ... @classmethod def from_tree(cls, node: _ChildSerialisableTreeElement) -> Self: ... diff --git a/stubs/openpyxl/openpyxl/worksheet/pagebreak.pyi b/stubs/openpyxl/openpyxl/worksheet/pagebreak.pyi index aaa8b55d44a6..7b6a1f6dac2a 100644 --- a/stubs/openpyxl/openpyxl/worksheet/pagebreak.pyi +++ b/stubs/openpyxl/openpyxl/worksheet/pagebreak.pyi @@ -33,9 +33,9 @@ class RowBreak(Serialisable): def __bool__(self) -> bool: ... def __len__(self) -> int: ... @property - def count(self): ... + def count(self) -> int: ... @property - def manualBreakCount(self): ... + def manualBreakCount(self) -> int: ... def append(self, brk: Incomplete | None = None) -> None: ... PageBreak = RowBreak diff --git a/stubs/openpyxl/openpyxl/worksheet/protection.pyi b/stubs/openpyxl/openpyxl/worksheet/protection.pyi index 90ddad654bc3..bac5c14af1b9 100644 --- a/stubs/openpyxl/openpyxl/worksheet/protection.pyi +++ b/stubs/openpyxl/openpyxl/worksheet/protection.pyi @@ -1,16 +1,21 @@ from _typeshed import Incomplete -from typing import ClassVar +from typing import ClassVar, overload from typing_extensions import Literal from openpyxl.descriptors.base import Alias, Bool, Integer, String, _ConvertibleToBool, _ConvertibleToInt from openpyxl.descriptors.serialisable import Serialisable class _Protected: - def set_password(self, value: str = "", already_hashed: bool = False) -> None: ... + @overload + def set_password(self, value: str = "", already_hashed: Literal[False] = False) -> None: ... + @overload + def set_password(self, value: str | None, already_hashed: Literal[True]) -> None: ... + @overload + def set_password(self, value: str | None = "", *, already_hashed: Literal[True]) -> None: ... @property - def password(self): ... + def password(self) -> str | None: ... @password.setter - def password(self, value) -> None: ... + def password(self, value: str) -> None: ... class SheetProtection(Serialisable, _Protected): tagname: ClassVar[str] @@ -61,7 +66,12 @@ class SheetProtection(Serialisable, _Protected): spinCount: _ConvertibleToInt | None = None, hashValue: Incomplete | None = None, ) -> None: ... - def set_password(self, value: str = "", already_hashed: bool = False) -> None: ... + @overload + def set_password(self, value: str = "", already_hashed: Literal[False] = False) -> None: ... + @overload + def set_password(self, value: str | None, already_hashed: Literal[True]) -> None: ... + @overload + def set_password(self, value: str | None = "", *, already_hashed: Literal[True]) -> None: ... def enable(self) -> None: ... def disable(self) -> None: ... def __bool__(self) -> bool: ... diff --git a/stubs/openpyxl/openpyxl/worksheet/scenario.pyi b/stubs/openpyxl/openpyxl/worksheet/scenario.pyi index cb5c04e46bd5..6229287a52ba 100644 --- a/stubs/openpyxl/openpyxl/worksheet/scenario.pyi +++ b/stubs/openpyxl/openpyxl/worksheet/scenario.pyi @@ -76,7 +76,7 @@ class Scenario(Serialisable): comment: str | None = None, ) -> None: ... @property - def count(self): ... + def count(self) -> int: ... class ScenarioList(Serialisable): tagname: ClassVar[str] diff --git a/stubs/openpyxl/openpyxl/worksheet/table.pyi b/stubs/openpyxl/openpyxl/worksheet/table.pyi index 03f0e0ffb361..8c6a5fd829c7 100644 --- a/stubs/openpyxl/openpyxl/worksheet/table.pyi +++ b/stubs/openpyxl/openpyxl/worksheet/table.pyi @@ -197,9 +197,9 @@ class Table(Serialisable): ) -> None: ... def to_tree(self): ... @property - def path(self): ... + def path(self) -> str: ... @property - def column_names(self): ... + def column_names(self) -> list[str]: ... class TablePartList(Serialisable): tagname: ClassVar[str] @@ -211,7 +211,7 @@ class TablePartList(Serialisable): def __init__(self, count: Unused = None, tablePart=()) -> None: ... def append(self, part) -> None: ... @property - def count(self): ... + def count(self) -> int: ... def __bool__(self) -> bool: ... class TableList(dict[Incomplete, Incomplete]): diff --git a/stubs/openpyxl/openpyxl/worksheet/worksheet.pyi b/stubs/openpyxl/openpyxl/worksheet/worksheet.pyi index b0216d0cad8f..0ff538d7a6d8 100644 --- a/stubs/openpyxl/openpyxl/worksheet/worksheet.pyi +++ b/stubs/openpyxl/openpyxl/worksheet/worksheet.pyi @@ -1,11 +1,12 @@ from _typeshed import Incomplete from collections.abc import Generator, Iterable, Iterator from datetime import datetime -from typing import Any, overload +from typing import Any, NoReturn, overload from typing_extensions import Final, Literal from openpyxl import _Decodable, _VisibilityType -from openpyxl.cell.cell import Cell, _CellValue +from openpyxl.cell import _CellValue +from openpyxl.cell.cell import Cell from openpyxl.formatting.formatting import ConditionalFormattingList from openpyxl.workbook.child import _WorkbookChild from openpyxl.workbook.defined_name import DefinedNameDict @@ -71,22 +72,22 @@ class Worksheet(_WorkbookChild): @property def sheet_view(self) -> SheetView: ... @property - def selected_cell(self) -> Cell: ... + def selected_cell(self) -> str | None: ... @property - def active_cell(self) -> Cell: ... + def active_cell(self) -> str | None: ... @property - def array_formulae(self) -> dict[Incomplete, Incomplete]: ... + def array_formulae(self) -> dict[str, str]: ... @property - def show_gridlines(self) -> bool: ... + def show_gridlines(self) -> bool | None: ... @property def freeze_panes(self) -> str | None: ... @freeze_panes.setter - def freeze_panes(self, topLeftCell: Incomplete | None = ...) -> None: ... + def freeze_panes(self, topLeftCell: str | Cell | None = ...) -> None: ... def cell(self, row: int, column: int, value: str | None = None) -> Cell: ... @overload def __getitem__(self, key: int | slice) -> tuple[Cell, ...]: ... @overload - def __getitem__(self, key: str) -> Any: ... # Cell | tuple[Cell, ...] + def __getitem__(self, key: str) -> Any: ... # AnyOf[Cell, tuple[Cell, ...]] def __setitem__(self, key: str, value: str) -> None: ... def __iter__(self) -> Iterator[Cell]: ... def __delitem__(self, key: str) -> None: ... @@ -180,7 +181,7 @@ class Worksheet(_WorkbookChild): values_only: bool, ) -> Generator[tuple[Cell | str | float | datetime | None, ...], None, None]: ... @property - def columns(self) -> Generator[Cell, None, None]: ... + def columns(self) -> Generator[tuple[Cell, ...], None, None]: ... def set_printer_settings( self, paper_size: int | None, orientation: None | Literal["default", "portrait", "landscape"] ) -> None: ... @@ -199,8 +200,9 @@ class Worksheet(_WorkbookChild): end_row: int | None = None, end_column: int | None = None, ) -> None: ... + # deprecated: Will always raise: TypeError: 'set' object is not subscriptable @property - def merged_cell_ranges(self) -> list[CellRange]: ... + def merged_cell_ranges(self) -> NoReturn: ... def unmerge_cells( self, range_string: str | None = None, @@ -224,8 +226,8 @@ class Worksheet(_WorkbookChild): @print_title_cols.setter def print_title_cols(self, cols: str | None) -> None: ... @property - def print_titles(self) -> str | None: ... + def print_titles(self) -> str: ... @property - def print_area(self) -> list[str]: ... + def print_area(self) -> str: ... @print_area.setter - def print_area(self, value: str | Iterable[str]) -> None: ... + def print_area(self, value: str | Iterable[str] | None) -> None: ...