mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-10 05:51:52 +08:00
openpyxl TypeGuards and comparison dunders (#10962)
This commit is contained in:
@@ -15,8 +15,8 @@ class ReadOnlyCell:
|
||||
column: Incomplete
|
||||
data_type: Incomplete
|
||||
def __init__(self, sheet, row, column, value, data_type: str = "n", style_id: int = 0) -> None: ...
|
||||
def __eq__(self, other): ...
|
||||
def __ne__(self, other): ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
def __ne__(self, other: object) -> bool: ...
|
||||
# Same as Cell.coordinate
|
||||
# Defined twice in the implementation
|
||||
@property
|
||||
|
||||
@@ -39,7 +39,7 @@ class Reference(Strict):
|
||||
range_string: str | None = None,
|
||||
) -> None: ...
|
||||
def __len__(self) -> int: ...
|
||||
def __eq__(self, other): ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
@property
|
||||
def rows(self) -> Generator[Reference, None, None]: ...
|
||||
@property
|
||||
|
||||
@@ -9,7 +9,7 @@ class Comment:
|
||||
def __init__(self, text, author, height: int = 79, width: int = 144) -> None: ...
|
||||
@property
|
||||
def parent(self) -> Any: ... # AnyOf[Cell, MergedCell, ReadOnlyCell]
|
||||
def __eq__(self, other): ...
|
||||
def __eq__(self, other: Comment) -> bool: ... # type: ignore[override]
|
||||
def __copy__(self): ...
|
||||
def bind(self, cell) -> None: ...
|
||||
def unbind(self) -> None: ...
|
||||
|
||||
@@ -36,8 +36,8 @@ class Serialisable(metaclass=MetaSerialisable):
|
||||
def from_tree(cls, node: _SerialisableTreeElement) -> Self | None: ...
|
||||
def to_tree(self, tagname: str | None = None, idx: Incomplete | None = None, namespace: str | None = None): ...
|
||||
def __iter__(self) -> Iterator[tuple[str, str]]: ...
|
||||
def __eq__(self, other): ...
|
||||
def __ne__(self, other): ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
def __ne__(self, other: object) -> bool: ...
|
||||
def __hash__(self) -> int: ...
|
||||
def __add__(self, other): ...
|
||||
def __copy__(self): ...
|
||||
|
||||
@@ -5,7 +5,7 @@ from typing_extensions import Literal
|
||||
|
||||
from openpyxl.descriptors.base import Alias, Bool, Convertible, _ConvertibleToBool, _ConvertibleToMultiCellRange
|
||||
from openpyxl.descriptors.serialisable import Serialisable
|
||||
from openpyxl.worksheet.cell_range import MultiCellRange
|
||||
from openpyxl.worksheet.cell_range import CellRange, MultiCellRange
|
||||
|
||||
class ConditionalFormatting(Serialisable):
|
||||
tagname: ClassVar[str]
|
||||
@@ -17,9 +17,9 @@ class ConditionalFormatting(Serialisable):
|
||||
def __init__(
|
||||
self, sqref: _ConvertibleToMultiCellRange = (), pivot: _ConvertibleToBool | None = None, cfRule=(), extLst: Unused = None
|
||||
) -> None: ...
|
||||
def __eq__(self, other): ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
def __hash__(self) -> int: ...
|
||||
def __contains__(self, coord): ...
|
||||
def __contains__(self, coord: str | CellRange) -> bool: ...
|
||||
|
||||
class ConditionalFormattingList:
|
||||
max_priority: int
|
||||
|
||||
@@ -35,7 +35,7 @@ class Manifest(Serialisable):
|
||||
@property
|
||||
def extensions(self) -> list[tuple[str, str]]: ...
|
||||
def to_tree(self): ...
|
||||
def __contains__(self, content_type): ...
|
||||
def __contains__(self, content_type: str) -> bool: ...
|
||||
def find(self, content_type): ...
|
||||
def findall(self, content_type) -> Generator[Incomplete, None, None]: ...
|
||||
def append(self, obj) -> None: ...
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from _typeshed import Incomplete, Unused
|
||||
from re import Pattern
|
||||
from typing import ClassVar
|
||||
from typing_extensions import Final, Literal
|
||||
from typing import ClassVar, overload
|
||||
from typing_extensions import Final, Literal, TypeGuard
|
||||
|
||||
from openpyxl.descriptors import Strict, String
|
||||
from openpyxl.descriptors.base import Integer, _ConvertibleToInt
|
||||
@@ -51,12 +51,18 @@ LOCALE_GROUP: Final = r"\[(?!hh?\]|mm?\]|ss?\])[^\]]*\]"
|
||||
STRIP_RE: Final[Pattern[str]]
|
||||
TIMEDELTA_RE: Final[Pattern[str]]
|
||||
|
||||
def is_date_format(fmt) -> bool: ...
|
||||
def is_timedelta_format(fmt): ...
|
||||
def is_datetime(fmt): ...
|
||||
def is_builtin(fmt): ...
|
||||
def is_date_format(fmt: str | None) -> TypeGuard[str]: ...
|
||||
def is_timedelta_format(fmt: str | None) -> TypeGuard[str]: ...
|
||||
@overload
|
||||
def is_datetime(fmt: None) -> None: ...
|
||||
@overload
|
||||
def is_datetime(fmt: str) -> Literal["datetime", "date", "time"] | None: ...
|
||||
def is_builtin(fmt: str | None) -> TypeGuard[str]: ...
|
||||
def builtin_format_code(index): ...
|
||||
def builtin_format_id(fmt): ...
|
||||
@overload
|
||||
def builtin_format_id(fmt: None) -> None: ...
|
||||
@overload
|
||||
def builtin_format_id(fmt: str) -> int | None: ...
|
||||
|
||||
class NumberFormatDescriptor(String[Incomplete]):
|
||||
def __set__(self, instance: Serialisable | Strict, value) -> None: ...
|
||||
|
||||
@@ -5,5 +5,5 @@ class StyleProxy:
|
||||
def __copy__(self): ...
|
||||
def __add__(self, other): ...
|
||||
def copy(self, **kw): ...
|
||||
def __eq__(self, other): ...
|
||||
def __ne__(self, other): ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
def __ne__(self, other: object) -> bool: ...
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
from _typeshed import Incomplete
|
||||
from collections.abc import Iterable
|
||||
from typing import TypeVar
|
||||
|
||||
class IndexedList(list[Incomplete]):
|
||||
_T = TypeVar("_T")
|
||||
|
||||
class IndexedList(list[_T]):
|
||||
clean: bool
|
||||
def __init__(self, iterable: Incomplete | None = None) -> None: ...
|
||||
def __contains__(self, value): ...
|
||||
def index(self, value): ...
|
||||
def append(self, value) -> None: ...
|
||||
def add(self, value): ...
|
||||
def __init__(self, iterable: Iterable[_T] | None = None) -> None: ...
|
||||
def __contains__(self, value: object) -> bool: ...
|
||||
def index(self, value: _T): ... # type: ignore[override]
|
||||
def append(self, value: _T) -> None: ...
|
||||
def add(self, value: _T): ...
|
||||
|
||||
@@ -18,7 +18,7 @@ class CellRange(Serialisable):
|
||||
@overload
|
||||
def __init__(
|
||||
self,
|
||||
range_string: str | None,
|
||||
range_string: str,
|
||||
min_col: Unused = None,
|
||||
min_row: Unused = None,
|
||||
max_col: Unused = None,
|
||||
@@ -48,16 +48,16 @@ class CellRange(Serialisable):
|
||||
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): ...
|
||||
def __eq__(self, other): ...
|
||||
def issubset(self, other): ...
|
||||
def __ne__(self, other: object) -> bool: ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
def issubset(self, other: CellRange) -> bool: ...
|
||||
__le__ = issubset
|
||||
def __lt__(self, other): ...
|
||||
def issuperset(self, other): ...
|
||||
def __lt__(self, other: CellRange) -> bool: ...
|
||||
def issuperset(self, other: CellRange) -> bool: ...
|
||||
__ge__ = issuperset
|
||||
def __contains__(self, coord): ...
|
||||
def __gt__(self, other): ...
|
||||
def isdisjoint(self, other): ...
|
||||
def __contains__(self, coord: str) -> bool: ...
|
||||
def __gt__(self, other: CellRange) -> bool: ...
|
||||
def isdisjoint(self, other: CellRange) -> bool: ...
|
||||
def intersection(self, other): ...
|
||||
__and__ = intersection
|
||||
def union(self, other): ...
|
||||
@@ -80,12 +80,12 @@ class CellRange(Serialisable):
|
||||
class MultiCellRange(Strict):
|
||||
ranges: Incomplete
|
||||
def __init__(self, ranges=...) -> None: ...
|
||||
def __contains__(self, coord): ...
|
||||
def __contains__(self, coord: str | CellRange) -> bool: ...
|
||||
def sorted(self) -> list[CellRange]: ...
|
||||
def add(self, coord) -> None: ...
|
||||
def __iadd__(self, coord): ...
|
||||
def __eq__(self, other): ...
|
||||
def __ne__(self, other): ...
|
||||
def __eq__(self, other: str | MultiCellRange) -> bool: ... # type: ignore[override]
|
||||
def __ne__(self, other: str | MultiCellRange) -> bool: ... # type: ignore[override]
|
||||
def __bool__(self) -> bool: ...
|
||||
def remove(self, coord) -> None: ...
|
||||
def __iter__(self) -> Iterator[CellRange]: ...
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from _typeshed import Incomplete
|
||||
from typing import ClassVar
|
||||
from typing import ClassVar, Protocol
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
from openpyxl.descriptors.base import (
|
||||
@@ -15,7 +15,7 @@ from openpyxl.descriptors.base import (
|
||||
)
|
||||
from openpyxl.descriptors.nested import NestedText
|
||||
from openpyxl.descriptors.serialisable import Serialisable
|
||||
from openpyxl.worksheet.cell_range import MultiCellRange
|
||||
from openpyxl.worksheet.cell_range import CellRange, MultiCellRange
|
||||
|
||||
_DataValidationType: TypeAlias = Literal["whole", "decimal", "list", "date", "time", "textLength", "custom"]
|
||||
_DataValidationErrorStyle: TypeAlias = Literal["stop", "warning", "information"]
|
||||
@@ -36,6 +36,9 @@ _DataValidationOperator: TypeAlias = Literal[
|
||||
"between", "notBetween", "equal", "notEqual", "lessThan", "lessThanOrEqual", "greaterThan", "greaterThanOrEqual"
|
||||
]
|
||||
|
||||
class _HasCoordinate(Protocol):
|
||||
coordinate: str | CellRange
|
||||
|
||||
def collapse_cell_addresses(cells, input_ranges=()): ...
|
||||
def expand_cell_ranges(range_string): ...
|
||||
|
||||
@@ -81,7 +84,7 @@ class DataValidation(Serialisable):
|
||||
allow_blank: Incomplete | None = False,
|
||||
) -> None: ...
|
||||
def add(self, cell) -> None: ...
|
||||
def __contains__(self, cell): ...
|
||||
def __contains__(self, cell: _HasCoordinate | str | CellRange) -> bool: ...
|
||||
|
||||
class DataValidationList(Serialisable):
|
||||
tagname: ClassVar[str]
|
||||
|
||||
@@ -30,5 +30,5 @@ class MergedCellRange(CellRange):
|
||||
start_cell: Incomplete
|
||||
def __init__(self, worksheet, coord) -> None: ...
|
||||
def format(self) -> None: ...
|
||||
def __contains__(self, coord): ...
|
||||
def __contains__(self, coord: str) -> bool: ...
|
||||
def __copy__(self): ...
|
||||
|
||||
@@ -48,4 +48,4 @@ class PrintArea(MultiCellRange):
|
||||
@classmethod
|
||||
def from_string(cls, value) -> Self: ...
|
||||
def __init__(self, ranges=(), title: Unused = "") -> None: ...
|
||||
def __eq__(self, other): ...
|
||||
def __eq__(self, other: str | MultiCellRange) -> bool: ... # type: ignore[override]
|
||||
|
||||
Reference in New Issue
Block a user