openpyxl: Type styleable descriptors (#11103)

This commit is contained in:
Avasam
2023-12-05 04:41:41 -05:00
committed by GitHub
parent 5521da8e92
commit 23b0291176
2 changed files with 46 additions and 42 deletions

View File

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

View File

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