10000 Merge openpyxl stubs from microsoft/python-type-stubs by Avasam · Pull Request #9511 · python/typeshed · GitHub
[go: up one dir, main page]

Skip to content

Merge openpyxl stubs from microsoft/python-type-stubs #9511

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
e371358
Bring openpyxl stubs at least up to par with microsoft/python-type-stubs
Avasam Jan 10, 2023
f47d473
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Jan 11, 2023
e08d3ea
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Jan 12, 2023
9c14076
Include numpy
Avasam Jan 12, 2023
4e7fc09
Convertible Descriptors
Avasam Jan 12, 2023
8a9de85
Update after self-review
Avasam Jan 12, 2023
704399f
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Feb 8, 2023
dd5a152
Update tests
Avasam Feb 8, 2023
f11292d
Fix pytype errors
Avasam Feb 9, 2023
e3419bd
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Feb 21, 2023
7b034b2
Fixes
Avasam Feb 21, 2023
674f8ff
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Feb 23, 2023
093b061
PR comments
Avasam Feb 23, 2023
ba82470
quick CI fixes
Avasam Feb 23, 2023
9e63d21
failed at version checking
Avasam Feb 23, 2023
d1e618e
Apply suggestions from code review
Avasam Feb 28, 2023
6d6d1ce
Add alias _UnderlineType and update Self
Avasam Feb 28, 2023
567a1a8
Merge branch 'openpyxl-from-microsoft-python-type-stubs' of https://g…
Avasam Feb 28, 2023
12789fe
Post-merge fixes
Avasam Feb 28, 2023
bfb6c60
Make stubuploader tests pass
Avasam Feb 28, 2023
2a98afc
Merge branch 'main' into openpyxl-from-microsoft-python-type-stubs
AlexWaygood Mar 16, 2023
f5df850
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 16, 2023
028ac1c
Apply suggestions from code review
AlexWaygood Mar 16, 2023
6bdc7df
Update stubs/openpyxl/openpyxl/reader/workbook.pyi
AlexWaygood Mar 16, 2023
e5e4eb3
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Mar 22, 2023
7b9ccae
Merge branch 'main' into openpyxl-from-microsoft-python-type-stubs
srittau Mar 24, 2023
c7c24e8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 24, 2023
368a500
Merge branch 'openpyxl-from-microsoft-python-type-stubs' of https://g…
Avasam Mar 31, 2023
ed09fc2
Run stubdefaulter
Avasam Mar 31, 2023
b5fd48c
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Mar 31, 2023
feef334
Use new type aliases for params
Avasam May 10, 2023
bc66516
Type MetaSerialisable dunders
Avasam May 10, 2023
4bfc8fb
Merge branch 'Type-MetaSerialisable-dunders' of https://github.com/Av…
Avasam May 10, 2023
4a050d9
regroup __init__ in stubtest_allowlist
Avasam May 10, 2023
93c9bfc
.
Avasam May 10, 2023
a1f40c6
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam May 20, 2023
2557483
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Jun 12, 2023
ff8e704
Type openpyxl incomplete dunders
Avasam Jun 12, 2023
ac138f8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 12, 2023
031592c
Remove redundant suppressions
Avasam Jun 12, 2023
d856a33
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Jun 13, 2023
328001b
Merge branch 'openpyxl-incomplete-dunders' of https://github.com/Avas…
Avasam Jun 13, 2023
82d17a6
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Jun 15, 2023
c127da3
Merge branch 'openpyxl-incomplete-dunders' of https://github.com/Avas…
Avasam Jun 15, 2023
6331d8a
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Jul 23, 2023
ce181aa
_SerialisableTreeElement
Avasam Jul 23, 2023
a4fff41
openpyxl: Class properties set explicitely as another class'
Avasam Aug 9, 2023
7b2180d
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Aug 11, 2023
dba0b8d
Merge branch 'openpyxl-Class-properties-set-explicitely' of https://g…
Avasam Aug 11, 2023
aac6860
Complete openpyxl title type annotations
Avasam Aug 11, 2023
79bd5fe
Merge branch 'openpyxl-title' of https://github.com/Avasam/typeshed i…
Avasam Aug 12, 2023
0ba3633
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Aug 15, 2023
50a27a8
Fixes post merge
Avasam Aug 18, 2023
8c43a40
Complete `from_tree`
Avasam Aug 18, 2023
f5cb6fe
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Aug 21, 2023
491efaf
Serialisable.from_tree improvement to avoid override issues
Avasam Aug 21, 2023
94c8b66
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Sep 12, 2023
a2e8d15
Type usages of PIL and zipfile
Avasam Sep 12, 2023
f08c6f1
Update stubtest_allowlist
Avasam Sep 12, 2023
29c9218
Update `get_rel`
Avasam Sep 12, 2023
c32f3e2
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Sep 19, 2023
a27c72f
Merge branch 'openpyxl-external-types' of https://github.com/Avasam/t…
Avasam Sep 19, 2023
5a284d6
Extract PIL and zipfile to #10706
Avasam Sep 19, 2023
200c096
datetime and _FileRead changes and fixes
Avasam Sep 19, 2023
9eb96b8
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Oct 13, 2023
d0793fc
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Oct 16, 2023
b957b79
Revert some import changes to reduce changes
Avasam Oct 16, 2023
ae8101c
Generator send actually unknown
Avasam Oct 16, 2023
6f408a6
avoid backref
Avasam Oct 16, 2023
11446be
tagname stays classvar
Avasam Oct 16, 2023
1f66b3f
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Nov 1, 2023
2fbb0e3
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Nov 2, 2023
5fc62cc
non-complex extraction from 9511
Avasam Dec 1, 2023
cc96eb4
Fix CI failures
Avasam Dec 1, 2023
169ea20
create_sheet return type
Avasam Dec 1, 2023
c0521d1
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Dec 1, 2023
d491dd8
Merge branch 'main' of https://github.com/python/typeshed into non-co…
Avasam Dec 1, 2023
a74c7ef
Post-merge fix missing Element
Avasam Dec 1, 2023
c272267
Merge branch 'non-complex-extraction-from-9511' of https://github.com…
Avasam Dec 1, 2023
17ff8a0
.
Avasam Dec 1, 2023
fd5a9a9
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Dec 4, 2023
333054d
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Dec 6, 2023
b35695d
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Mar 6, 2024
3b0034b
Update stubs/openpyxl/openpyxl/worksheet/_reader.pyi
Avasam Mar 6, 2024
6290b35
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Mar 11, 2024
08e4e91
Merge branch 'openpyxl-from-microsoft-python-type-stubs' of https://g…
Avasam Mar 11, 2024
a9021fc
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Mar 13, 2024
2bf8906
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Apr 1, 2024
8db96b3
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Apr 8, 2024
e2f2720
Merge branch 'main' into openpyxl-from-microsoft-python-type-stubs
Avasam Aug 18, 2024
2979638
Merge branch 'main' into openpyxl-from-microsoft-python-type-stubs
Avasam Sep 23, 2024
9cd6ffe
openpyxl: `Cell | MergedCell` annotations
Avasam Nov 25, 2024
82b5fcc
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 25, 2024
e0d6119
lint fixes
Avasam Nov 25, 2024
f17d61c
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Nov 25, 2024
0b0b501
Rename _Cell to _CellOrMergedCell
Avasam Nov 25, 2024
1a6d68e
Merge branch 'openpyxl-Cell-or-MergedCell-annotations' of https://git…
Avasam Nov 25, 2024
3fe91a6
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam Nov 25, 2024
0542fd2
Merge branch 'main' of https://github.com/python/typeshed into openpy…
Avasam May 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Complete from_tree
  • Loading branch information
Avasam committed Aug 18, 2023
commit 8c43a40f9f2b75642e65b97bf1edbaf9a8f47878
6 changes: 3 additions & 3 deletions stubs/openpyxl/openpyxl/chart/axis.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ from openpyxl.descriptors.nested import (
NestedSet,
_NestedNoneSetParam,
)
from openpyxl.descriptors.serialisable import Serialisable, _SerialisableTreeElement
from openpyxl.descriptors.serialisable import Serialisable

from ..xml._functions_overloads import _HasTagAndGet
from ..xml._functions_overloads import _HasTagAndGet, _SupportsFindAndIterAndAttribAndText

_ScalingOrientation: TypeAlias = Literal["maxMin", "minMax"]
_BaseAxisAxPos: TypeAlias = Literal["b", "l", "r", "t"]
Expand Down Expand Up @@ -198,7 +198,7 @@ class NumericAxis(_BaseAxis):
**kw,
) -> None: ...
@classmethod
def from_tree(cls, node: _SerialisableTreeElement) -> Self: ...
def from_tree(cls, node: _SupportsFindAndIterAndAttribAndText) -> Self: ...

class TextAxis(_BaseAxis):
tagname: ClassVar[str]
Expand Down
6 changes: 3 additions & 3 deletions stubs/openpyxl/openpyxl/chart/plotarea.pyi
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from _typeshed import Incomplete, Unused
from typing import ClassVar
from typing_extensions import Literal
from typing_extensions import Literal, Self

from openpyxl.chart.layout import Layout
from openpyxl.chart.shapes import GraphicalProperties
from openpyxl.chart.text import RichText
from openpyxl.descriptors.base import Alias, Typed, _ConvertibleToBool
from openpyxl.descriptors.excel import ExtensionList
from openpyxl.descriptors.nested import NestedBool
from openpyxl.descriptors.serialisable import Serialisable, _SerialisableTreeElement
from openpyxl.descriptors.serialisable import Serialisable, _ChildSerialisableTreeElement

from ..xml._functions_overloads import _HasTagAndGet

Expand Down Expand Up @@ -73,4 +73,4 @@ class PlotArea(Serialisable):
) -> None: ...
def to_tree(self, tagname: str | None = None, idx: Incomplete | None = None, namespace: str | None = None): ...
@classmethod
def from_tree(cls, node: _SerialisableTreeElement): ...
def from_tree(cls, node: _ChildSerialisableTreeElement) -> Self: ...
8 changes: 4 additions & 4 deletions stubs/openpyxl/openpyxl/descriptors/nested.pyi
8000
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ from openpyxl.descriptors.serialisable import Serialisable
from openpyxl.drawing.fill import Blip
from openpyxl.xml.functions import Element

from ..xml._functions_overloads import _HasTagAndGet, _HasTagAndText
from ..xml._functions_overloads import _HasGet, _HasTagAndGet, _HasText
from .base import _M, _N, _T, _ConvertibleToBool, _ConvertibleToFloat, _ConvertibleToInt, _ExpectedTypeParam

_NestedNoneSetParam: TypeAlias = _HasTagAndGet[_T | Literal["none"] | None] | _T | Literal["none"] | None
Expand All @@ -35,7 +35,7 @@ class Nested(Descriptor[_T]):
) -> None: ...
def __get__(self, instance: Serialisable | Strict, cls: type | None) -> _T: ...
def __set__(self, instance: Serialisable | Strict, value: _HasTagAndGet[_T] | _T) -> None: ...
def from_tree(self, node: _HasTagAndGet[_T]) -> _T: ...
def from_tree(self, node: _HasGet[_T]) -> _T: ...
def to_tree(self, tagname: str | None = None, value: Incomplete | None = None, namespace: str | None = None) -> Element: ...

class NestedValue(Nested[_T], Convertible[_T, _N]): # type: ignore[misc]
Expand Down Expand Up @@ -150,7 +150,7 @@ class NestedText(NestedValue[_T, _N]):
# Anything else
@overload
def __set__(self: NestedText[_T, Literal[True]], instance: Serialisable | Strict, value: _T | int | Any | None) -> None: ...
def from_tree(self, node: _HasTagAndText) -> str: ... # type: ignore[override]
def from_tree(self, node: _HasText) -> str: ... # type: ignore[override]
def to_tree(self, tagname: str | None = None, value: Incomplete | None = None, namespace: str | None = None) -> Element: ...

class NestedFloat(NestedValue[float, _N], Float[_N]): # type: ignore[misc]
Expand Down Expand Up @@ -179,7 +179,7 @@ class NestedBool(NestedValue[bool, _N], Bool[_N]): # type: ignore[misc]
def __set__( # type:ignore[override] # Different restrictions
self, instance: Serialisable | Strict, value: _HasTagAndGet[_ConvertibleToBool] | _ConvertibleToBool
) -> None: ...
def from_tree(self, node) -> bool: ... # type: ignore[override] # Actual overriden return type
def from_tree(self, node: _HasGet[bool]) -> bool: ... # type: ignore[override] # Actual overriden return type

class Nest 77F4 edNoneSet(Nested[_T | None], NoneSet[_T]): # type: ignore[misc]
def __init__(self, name: str | None = None, *, values: Iterable[_T | None]) -> None: ...
Expand Down
19 changes: 15 additions & 4 deletions stubs/openpyxl/openpyxl/descriptors/sequence.pyi
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
from _typeshed import Incomplete, Unused
from collections.abc import Generator
from collections.abc import Generator, Iterable
from typing import Any, Protocol, TypeVar
from typing_extensions import Self

from openpyxl.descriptors import Strict
from openpyxl.descriptors.serialisable import Serialisable
from openpyxl.descriptors.serialisable import Serialisable, _SerialisableTreeElement
from openpyxl.xml._functions_overloads import _HasGet

from .base import Alias, Descriptor

_T = TypeVar("_T")

class _SupportsFromTree(Protocol):
@classmethod
def from_tree(cls, node: _SerialisableTreeElement) -> Any: ...

class Sequence(Descriptor[Incomplete]):
expected_type: type[Incomplete]
seq_types: tuple[type, ...]
Expand All @@ -23,12 +31,15 @@ class UniqueSequence(Sequence):
class ValueSequence(Sequence):
attribute: str
def to_tree(self, tagname, obj, namespace: str | None = None) -> Generator[Incomplete, None, None]: ...
def from_tree(self, node): ...
def from_tree(self, node: _HasGet[_T]) -> _T: ...

class NestedSequence(Sequence):
count: bool
expected_type: type[_SupportsFromTree]
def to_tree(self, tagname, obj, namespace: str | None = None): ...
def from_tree(self, node): ...
# returned list generic type should be same as the return type of expected_type.from_tree(node)
# Which can really be anything given the wildly different, and sometimes generic, from_tree return types
def from_tree(self, node: Iterable[_SerialisableTreeElement]) -> list[Any]: ...

class MultiSequence(Sequence):
def __set__(self, instance: Serialisable | Strict, seq) -> None: ...
Expand Down
10 changes: 4 additions & 6 deletions stubs/openpyxl/openpyxl/descriptors/serialisable.pyi
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
from _typeshed import Incomplete, SupportsIter
from typing import Any, ClassVar, NoReturn, Protocol
from typing_extensions import Final
from typing_extensions import Final, Self

from openpyxl.descriptors import MetaSerialisable

from ..xml._functions_overloads import _HasAttrib, _HasTagAndGet, _HasText
from ..xml._functions_overloads import _HasAttrib, _HasGet, _HasText, _SupportsFind

# For any override directly re-using Serialisable.from_tree
class _ChildSerialisableTreeElement(_HasAttrib, _HasText, SupportsIter[Incomplete], Protocol): ...

class _SerialisableTreeElement(_HasTagAndGet[Incomplete], _ChildSerialisableTreeElement, Protocol):
def find(self, __path: str) -> Incomplete | None: ...
class _SerialisableTreeElement(_HasGet[object], _SupportsFind, _ChildSerialisableTreeElement, Protocol): ...

KEYWORDS: Final[frozenset[str]]
seq_types: Final[tuple[type[list[Any]], type[tuple[Any, ...]]]]
Expand All @@ -31,7 +29,7 @@ class Serialisable(metaclass=MetaSerialisable):
# Child classes should be more precise than _SerialisableTreeElement !
# Use _ChildSerialisableTreeElement instead for child classes that reuse Serialisable.from_tree directly.
@classmethod
def from_tree(cls, node: _SerialisableTreeElement): ...
def from_tree(cls, node: _SerialisableTreeElement) -> Self: ...
def to_tree(self, tagname: str | None = None, idx: Incomplete | None = None, namespace: str | None = None): ...
def __iter__(self): ...
def __eq__(self, other): ...
Expand Down
3 changes: 2 additions & 1 deletion stubs/openpyxl/openpyxl/packaging/custom.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ from openpyxl.descriptors.base import (
_ConvertibleToInt,
)
from openpyxl.descriptors.nested import NestedText
from openpyxl.descriptors.serialisable import _ChildSerialisableTreeElement

_T = TypeVar("_T")

Expand Down Expand Up @@ -57,7 +58,7 @@ class CustomPropertyList(Strict):
props: Sequence
def __init__(self) -> None: ...
@classmethod
def from_tree(cls, tree) -> Self: ...
def from_tree(cls, tree: _ChildSerialisableTreeElement) -> Self: ...
def append(self, prop) -> None: ...
def to_tree(self): ...
def __len__(self) -> int: ...
Expand Down
11 changes: 7 additions & 4 deletions stubs/openpyxl/openpyxl/styles/fills.pyi
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from _typeshed import Incomplete, Unused
from collections.abc import Generator
from collections.abc import Generator, Iterable, Sequence as ABCSequence
from typing import ClassVar
from typing_extensions import Final, Literal, Self, TypeAlias
from typing_extensions import Final, Literal, TypeAlias

from openpyxl.descriptors import Sequence, Strict
from openpyxl.descriptors.base import Alias, Float, MinMax, NoneSet, Set, _ConvertibleToFloat
from openpyxl.descriptors.serialisable import Serialisable, _SerialisableTreeElement
from openpyxl.descriptors.serialisable import Serialisable
from openpyxl.xml.functions import Element

from ..xml._functions_overloads import _SupportsIterAndAttribAndTextAndTag
from .colors import Color

FILL_NONE: Final = "none"
Expand Down Expand Up @@ -56,7 +57,9 @@ fills: Final[tuple[_FillsType, ...]]
class Fill(Serialisable):
tagname: ClassVar[str]
@classmethod
def from_tree(cls, el: _SerialisableTreeElement) -> Self: ...
def from_tree( # type: ignore[override]
cls, el: Iterable[ABCSequence[_SupportsIterAndAttribAndTextAndTag]]
) -> PatternFill | GradientFill | None: ...

class PatternFill(Fill):
tagname: ClassVar[str]
Expand Down
6 changes: 3 additions & 3 deletions stubs/openpyxl/openpyxl/styles/fonts.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ from openpyxl.descriptors.nested import (
NestedString,
_NestedNoneSetParam,
)
from openpyxl.descriptors.serialisable import Serialisable, _SerialisableTreeElement
from openpyxl.descriptors.serialisable import Serialisable

from ..xml._functions_overloads import _HasTagAndGet
from ..xml._functions_overloads import _HasTagAndGet, _SupportsFindAndIterAndAttribAndText
from .colors import Color

_FontU: TypeAlias = Literal["single", "double", "singleAccounting", "doubleAccounting"]
Expand Down Expand Up @@ -72,6 +72,6 @@ class Font(Serialisable):
extend: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None,
) -> None: ...
@classmethod
def from_tree(cls, node: _SerialisableTreeElement) -> Self: ...
def from_tree(cls, node: _SupportsFindAndIterAndAttribAndText) -> Self: ...

DEFAULT_FONT: Final[Font]
4 changes: 2 additions & 2 deletions stubs/openpyxl/openpyxl/styles/stylesheet.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ from typing_extensions import Literal

from openpyxl.descriptors.base import Typed
from openpyxl.descriptors.excel import ExtensionList
from openpyxl.descriptors.serialisable import Serialisable, _SerialisableTreeElement
from openpyxl.descriptors.serialisable import Serialisable, _ChildSerialisableTreeElement
from openpyxl.styles.cell_style import CellStyleList
from openpyxl.styles.colors import ColorList
from openpyxl.styles.named_styles import _NamedCellStyleList
Expand Down Expand Up @@ -45,7 +45,7 @@ class Stylesheet(Serialisable):
extLst: Unused = None,
) -> None: ...
@classmethod
def from_tree(cls, node: _SerialisableTreeElement): ...
def from_tree(cls, node: _ChildSerialisableTreeElement): ...
@property
def custom_formats(self): ...
def to_tree(self, tagname: str | None = None, idx: Incomplete | None = None, namespace: str | None = None): ...
Expand Down
8 changes: 5 additions & 3 deletions stubs/openpyxl/openpyxl/workbook/protection.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from _typeshed import Incomplete
from typing import ClassVar
from typing_extensions import Literal
from typing_extensions import Literal, Self

from openpyxl.descriptors.base import Alias, Bool, Integer, String, _ConvertibleToBool, _ConvertibleToInt
from openpyxl.descriptors.serialisable import Serialisable, _SerialisableTreeElement
from openpyxl.descriptors.serialisable import Serialisable

from ..xml._functions_overloads import _SupportsIterAndAttribAndTextAndGet

class WorkbookProtection(Serialisable):
tagname: ClassVar[str]
Expand Down Expand Up @@ -55,7 +57,7 @@ class WorkbookProtection(Serialisable):
@revisionsPassword.setter
def revisionsPassword(self, value) -> None: ...
@classmethod
def from_tree(cls, node: _SerialisableTreeElement): ...
def from_tree(cls, node: _SupportsIterAndAttribAndTextAndGet) -> Self: ...

DocumentSecurity = WorkbookProtection

Expand Down
6 changes: 4 additions & 2 deletions stubs/openpyxl/openpyxl/worksheet/header_footer.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from re import Pattern
from typing import ClassVar
from typing_extensions import Final, Literal
from typing_extensions import Final, Literal, Self

from openpyxl.descriptors import Strict
from openpyxl.descriptors.base import Alias, Bool, Integer, MatchPattern, String, Typed, _ConvertibleToBool, _ConvertibleToInt
from openpyxl.descriptors.serialisable import Serialisable

from ..xml._functions_overloads import _HasText

FONT_PATTERN: Final = '&"(?P<font>.+)"'
COLOR_PATTERN: Final = "&K(?P<color>[A-F0-9]{6})"
SIZE_REGEX: Final = r"&(?P<size>\d+\s?)"
Expand Down Expand Up @@ -38,7 +40,7 @@ class HeaderFooterItem(Strict):
def __bool__(self) -> bool: ...
def to_tree(self, tagname): ...
@classmethod
def from_tree(cls, node): ...
def from_tree(cls, node: _HasText) -> Self: ...

class HeaderFooter(Serialisable):
tagname: ClassVar[str]
Expand Down
6 changes: 3 additions & 3 deletions stubs/openpyxl/openpyxl/worksheet/page.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from _typeshed import Incomplete
from typing import ClassVar
from typing_extensions import Literal, TypeAlias
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, _SerialisableTreeElement
from openpyxl.descriptors.serialisable import Serialisable, _ChildSerialisableTreeElement

_PrintPageSetupOrientation: TypeAlias = Literal["default", "portrait", "landscape"]
_PrintPageSetupPageOrder: TypeAlias = Literal["downThenOver", "overThenDown"]
Expand Down Expand Up @@ -66,7 +66,7 @@ class PrintPageSetup(Serialisable):
@autoPageBreaks.setter
def autoPageBreaks(self, value) -> None: ...
@classmethod
def from_tree(cls, node: _SerialisableTreeElement): ...
def from_tree(cls, node: _ChildSerialisableTreeElement) -> Self: ...

class PrintOptions(Serialisable):
tagname: ClassVar[str]
Expand Down
6 changes: 3 additions & 3 deletions stubs/openpyxl/openpyxl/worksheet/table.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from _typeshed import Incomplete, Unused
from typing import ClassVar, overload
from typing_extensions import Final, Literal, TypeAlias
from typing_extensions import Final, Literal, Self, TypeAlias

from openpyxl.descriptors import Strict, String
from openpyxl.descriptors.base import Alias, Bool, Integer, NoneSet, Typed, _ConvertibleToBool, _ConvertibleToInt
from openpyxl.descriptors.excel import ExtensionList
from openpyxl.descriptors.serialisable import Serialisable, _SerialisableTreeElement
from openpyxl.descriptors.serialisable import Serialisable, _ChildSerialisableTreeElement
from openpyxl.worksheet.filters import AutoFilter, SortState

_TableColumnTotalsRowFunction: TypeAlias = Literal[
Expand Down Expand Up @@ -129,7 +129,7 @@ class TableColumn(Serialisable):
) -> None: ...
def __iter__(self): ...
@classmethod
def from_tree(cls, node: _SerialisableTreeElement): ...
def from_tree(cls, node: _ChildSerialisableTreeElement) -> Self: ...

class TableNameDescriptor(String[Incomplete]):
def __set__(self, instance: Serialisable | Strict, value) -> None: ...
Expand Down
17 changes: 15 additions & 2 deletions stubs/openpyxl/openpyxl/xml/_functions_overloads.pyi
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# This file does not exist at runtime. It is a helper file to overload imported functions in openpyxl.xml.functions

import sys
from _typeshed import Incomplete, ReadableBuffer
from _typeshed import Incomplete, ReadableBuffer, SupportsIter
from collections.abc import Iterable, Iterator, Mapping, Sequence
from typing import Any, Protocol, TypeVar, overload
from typing_extensions import TypeAlias
from xml.etree.ElementTree import Element, ElementTree, QName, XMLParser, _FileRead

from openpyxl.chart.axis import ChartLines

_T = TypeVar("_T")
_T_co = TypeVar("_T_co", covariant=True)

Expand All @@ -23,11 +25,22 @@ class _HasText(Protocol):
class _HasAttrib(Protocol):
attrib: Iterable[Any] # AnyOf[dict[str, str], Iterable[tuple[str, str]]]

class _HasTagAndGet(_HasTag, Protocol[_T_co]):
class _HasGet(Protocol[_T_co]):
def get(self, __value: str) -> _T_co | None: ...

class _SupportsFind(Protocol):
def find(self, __path: str) -> ChartLines | None: ...

class _HasTagAndGet(_HasTag, _HasGet[_T_co], Protocol[_T_co]): ...
class _HasTagAndText(_HasTag, _HasText, Protocol): ... # noqa: Y046
class _HasTagAndTextAndAttrib(_HasTag, _HasText, _HasAttrib, Protocol): ... # noqa: Y046
class _SupportsFindAndIterAndAttribAndText( # noqa: Y046
_SupportsFind, SupportsIter[Incomplete], _HasAttrib, _HasText, Protocol
): ...
class _SupportsIterAndAttribAndTextAndTag(SupportsIter[Incomplete], _HasAttrib, _HasText, _HasTag, Protocol): ... # noqa: Y046
class _SupportsIterAndAttribAndTextAndGet( # noqa: Y046
SupportsIter[Incomplete], _HasAttrib, _HasText, _HasGet[Incomplete], Protocol
): ...

class _ParentElement(Protocol[_T]):
def makeelement(self, __tag: str, __attrib: dict[str, str]) -> _T: ...
Expand Down
0