diff --git a/stubs/openpyxl/openpyxl/styles/cell_style.pyi b/stubs/openpyxl/openpyxl/styles/cell_style.pyi index c15f7e6d1..630bf9fd1 100644 --- a/stubs/openpyxl/openpyxl/styles/cell_style.pyi +++ b/stubs/openpyxl/openpyxl/styles/cell_style.pyi @@ -1,34 +1,36 @@ from _typeshed import ConvertibleToInt, Incomplete, Unused from array import array -from collections.abc import Iterable -from typing import ClassVar +from collections.abc import Iterable, MutableSequence +from typing import ClassVar, Generic, TypeVar from typing_extensions import Literal, Self -from openpyxl.descriptors import Strict from openpyxl.descriptors.base import Bool, Integer, Typed, _ConvertibleToBool from openpyxl.descriptors.excel import ExtensionList from openpyxl.descriptors.serialisable import Serialisable from openpyxl.styles.alignment import Alignment from openpyxl.styles.protection import Protection -class ArrayDescriptor: - key: Incomplete - def __init__(self, key) -> None: ... - def __get__(self, instance: Serialisable | Strict, cls: Unused): ... - def __set__(self, instance: Serialisable | Strict, value) -> None: ... +_T = TypeVar("_T") + +class ArrayDescriptor(Generic[_T]): + key: int + def __init__(self, key: int) -> None: ... + def __get__(self, instance: MutableSequence[_T], cls: Unused) -> _T: ... + def __set__(self, instance: MutableSequence[_T], value: _T) -> None: ... class StyleArray(array[int]): tagname: ClassVar[str] - fontId: ArrayDescriptor - fillId: ArrayDescriptor - borderId: ArrayDescriptor - numFmtId: ArrayDescriptor - protectionId: ArrayDescriptor - alignmentId: ArrayDescriptor - pivotButton: ArrayDescriptor - quotePrefix: ArrayDescriptor - xfId: ArrayDescriptor + fontId: ArrayDescriptor[int] + fillId: ArrayDescriptor[int] + borderId: ArrayDescriptor[int] + numFmtId: ArrayDescriptor[int] + protectionId: ArrayDescriptor[int] + alignmentId: ArrayDescriptor[int] + pivotButton: ArrayDescriptor[int] + quotePrefix: ArrayDescriptor[int] + xfId: ArrayDescriptor[int] def __new__(cls, args: bytes | bytearray | Iterable[int] = [0, 0, 0, 0, 0, 0, 0, 0, 0]) -> Self: ... + def __init__(self, args: bytes | bytearray | Iterable[int] = [0, 0, 0, 0, 0, 0, 0, 0, 0]) -> None: ... def __hash__(self) -> int: ... def __copy__(self) -> StyleArray: ... def __deepcopy__(self, memo: Unused) -> StyleArray: ... diff --git a/stubs/openpyxl/openpyxl/styles/styleable.pyi b/stubs/openpyxl/openpyxl/styles/styleable.pyi index 4dfe4d235..50aef163e 100644 --- a/stubs/openpyxl/openpyxl/styles/styleable.pyi +++ b/stubs/openpyxl/openpyxl/styles/styleable.pyi @@ -1,46 +1,48 @@ from _typeshed import Incomplete, Unused -from warnings import warn as warn +from collections.abc import Iterable -from openpyxl.descriptors import Strict from openpyxl.descriptors.serialisable import Serialisable +from .named_styles import NamedStyle +from .proxy import StyleProxy + class StyleDescriptor: - collection: Incomplete - key: Incomplete - def __init__(self, collection, key) -> None: ... - def __set__(self, instance: Serialisable | Strict, value) -> None: ... - def __get__(self, instance: Serialisable | Strict, cls: Unused): ... + collection: str + key: str + def __init__(self, collection: str, key: str) -> None: ... + def __set__(self, instance: StyleableObject, value: Serialisable) -> None: ... + def __get__(self, instance: StyleableObject, cls: Unused) -> StyleProxy: ... class NumberFormatDescriptor: key: str collection: str - def __set__(self, instance: Serialisable | Strict, value) -> None: ... - def __get__(self, instance: Serialisable | Strict, cls: Unused): ... + def __set__(self, instance: StyleableObject, value: str) -> None: ... + def __get__(self, instance: StyleableObject, cls: Unused) -> str: ... class NamedStyleDescriptor: key: str collection: str - def __set__(self, instance: Serialisable | Strict, value) -> None: ... - def __get__(self, instance: Serialisable | Strict, cls: Unused): ... + def __set__(self, instance: StyleableObject, value: NamedStyle | str) -> None: ... + def __get__(self, instance: StyleableObject, cls: Unused) -> str: ... class StyleArrayDescriptor: - key: Incomplete - def __init__(self, key) -> None: ... - def __set__(self, instance: Serialisable | Strict, value) -> None: ... - def __get__(self, instance: Serialisable | Strict, cls: Unused): ... + key: str + def __init__(self, key: str) -> None: ... + def __set__(self, instance: StyleableObject, value: int) -> None: ... + def __get__(self, instance: StyleableObject, cls: Unused) -> bool: ... class StyleableObject: - font: Incomplete - fill: Incomplete - border: Incomplete - number_format: Incomplete - protection: Incomplete - alignment: Incomplete - style: Incomplete - quotePrefix: Incomplete - pivotButton: Incomplete + font: StyleDescriptor + fill: StyleDescriptor + border: StyleDescriptor + number_format: NumberFormatDescriptor + protection: StyleDescriptor + alignment: StyleDescriptor + style: NamedStyleDescriptor + quotePrefix: StyleArrayDescriptor + pivotButton: StyleArrayDescriptor parent: Incomplete - def __init__(self, sheet, style_array: Incomplete | None = None) -> None: ... + def __init__(self, sheet, style_array: bytes | bytearray | Iterable[int] | None = None) -> None: ... @property def style_id(self) -> int: ... @property