Type all @property in openpyxl (#10787)

This commit is contained in:
Avasam
2023-10-04 05:05:30 -04:00
committed by GitHub
parent 741f751c2e
commit c30c85dfcb
45 changed files with 245 additions and 174 deletions

View File

@@ -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
)

View File

@@ -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

View File

@@ -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

View File

@@ -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: ...

View File

@@ -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: ...

View File

@@ -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: ...

View File

@@ -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: ...

View File

@@ -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: ...

View File

@@ -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: ...

View File

@@ -6,4 +6,4 @@ class Image:
format: Incomplete
def __init__(self, img) -> None: ...
@property
def path(self): ...
def path(self) -> str: ...

View File

@@ -118,4 +118,4 @@ class SpreadsheetDrawing(Serialisable):
def __hash__(self) -> int: ...
def __bool__(self) -> bool: ...
@property
def path(self): ...
def path(self) -> str: ...

View File

@@ -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"

View File

@@ -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: ...

View File

@@ -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): ...

View File

@@ -101,4 +101,4 @@ class WorkbookPackage(Serialisable):
) -> None: ...
def to_tree(self): ...
@property
def active(self): ...
def active(self) -> int: ...

View File

@@ -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: ...

View File

@@ -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: ...

View File

@@ -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: ...

View File

@@ -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]: ...

View File

@@ -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): ...

View File

@@ -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]: ...

View File

@@ -40,4 +40,4 @@ class DifferentialStyleList(Serialisable):
def __bool__(self) -> bool: ...
def __getitem__(self, idx): ...
@property
def count(self): ...
def count(self) -> int: ...

View File

@@ -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: ...

View File

@@ -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): ...

View File

@@ -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: ...

View File

@@ -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): ...

View File

@@ -77,4 +77,4 @@ class TableStyleList(Serialisable):
tableStyle=(),
) -> None: ...
@property
def count(self): ...
def count(self) -> int: ...

View File

@@ -1 +1 @@
def hash_password(plaintext_password: str = ""): ...
def hash_password(plaintext_password: str = "") -> str: ...

View File

@@ -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: ...

View File

@@ -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]):

View File

@@ -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): ...

View File

@@ -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: ...

View File

@@ -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]

View File

@@ -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: ...

View File

@@ -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: ...

View File

@@ -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

View File

@@ -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]

View File

@@ -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]: ...

View File

@@ -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

View File

@@ -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: ...

View File

@@ -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

View File

@@ -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: ...

View File

@@ -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]

View File

@@ -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]):

View File

@@ -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: ...