Skip to content
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

Type openpyxl functions module and its usages #10322

Merged
merged 8 commits into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 7 additions & 6 deletions stubs/openpyxl/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# "cls" argument has wrong name in implementation.
openpyxl.descriptors.slots.AutoSlotProperties.__new__
# The actual runtime definition depends on what else is installed
# (lxml, defusedxml, et_xmlfile)
openpyxl.xml._functions_overloads
openpyxl.xml.functions.Element.__iter__
openpyxl.xml.functions.fromstring
openpyxl.xml.functions.iterparse
openpyxl.xml.functions.tostring

# Requires numpy to be installed
openpyxl.utils.dataframe

# Element can be imported from lxml or xml.etree, so the attributes can
# differ at runtime.
openpyxl.xml.functions.Element.*

# Fake getters
openpyxl\.descriptors\..*\.__get__

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
NestedString,
NestedText,
NestedValue,
_HasTagAndGet,
)
from openpyxl.descriptors.serialisable import Serialisable
from openpyxl.xml._functions_overloads import _HasTagAndGet
from openpyxl.xml.functions import Element

_ = object() # More concise discard object for casts
Expand Down
4 changes: 3 additions & 1 deletion stubs/openpyxl/openpyxl/chart/_3d.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ from openpyxl.chart.picture import PictureOptions
from openpyxl.chart.shapes import GraphicalProperties
from openpyxl.descriptors.base import Alias, Typed, _ConvertibleToBool, _ConvertibleToFloat, _ConvertibleToInt
from openpyxl.descriptors.excel import ExtensionList
from openpyxl.descriptors.nested import NestedBool, NestedInteger, NestedMinMax, _HasTagAndGet
from openpyxl.descriptors.nested import NestedBool, NestedInteger, NestedMinMax
from openpyxl.descriptors.serialisable import Serialisable

from ..xml._functions_overloads import _HasTagAndGet

class View3D(Serialisable):
tagname: ClassVar[str]
rotX: NestedMinMax[float, Literal[True]]
Expand Down
3 changes: 2 additions & 1 deletion stubs/openpyxl/openpyxl/chart/area_chart.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ from openpyxl.chart.axis import ChartLines, NumericAxis, SeriesAxis, TextAxis
from openpyxl.chart.label import DataLabelList
from openpyxl.descriptors.base import Alias, Typed, _ConvertibleToBool
from openpyxl.descriptors.excel import ExtensionList
from openpyxl.descriptors.nested import NestedBool, NestedSet, _HasTagAndGet
from openpyxl.descriptors.nested import NestedBool, NestedSet

from ..xml._functions_overloads import _HasTagAndGet
from ._chart import ChartBase

_AreaChartBaseGrouping: TypeAlias = Literal["percentStacked", "standard", "stacked"]
Expand Down
3 changes: 2 additions & 1 deletion stubs/openpyxl/openpyxl/chart/axis.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ from openpyxl.descriptors.nested import (
NestedMinMax,
NestedNoneSet,
NestedSet,
_HasTagAndGet,
_NestedNoneSetParam,
)
from openpyxl.descriptors.serialisable import Serialisable

from ..xml._functions_overloads import _HasTagAndGet

_ScalingOrientation: TypeAlias = Literal["maxMin", "minMax"]
_BaseAxisAxPos: TypeAlias = Literal["b", "l", "r", "t"]
_BaseAxisTickMark: TypeAlias = Literal["cross", "in", "out"]
Expand Down
3 changes: 2 additions & 1 deletion stubs/openpyxl/openpyxl/chart/bar_chart.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ from openpyxl.chart.axis import ChartLines, NumericAxis, SeriesAxis, TextAxis
from openpyxl.chart.label import DataLabelList
from openpyxl.descriptors.base import Alias, Typed, _ConvertibleToBool
from openpyxl.descriptors.excel import ExtensionList
from openpyxl.descriptors.nested import NestedBool, NestedNoneSet, NestedSet, _HasTagAndGet, _NestedNoneSetParam
from openpyxl.descriptors.nested import NestedBool, NestedNoneSet, NestedSet, _NestedNoneSetParam

from ..xml._functions_overloads import _HasTagAndGet
from ._3d import _3DBase
from ._chart import ChartBase

Expand Down
3 changes: 2 additions & 1 deletion stubs/openpyxl/openpyxl/chart/bubble_chart.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ from openpyxl.chart.axis import NumericAxis
from openpyxl.chart.label import DataLabelList
from openpyxl.descriptors.base import Alias, Typed, _ConvertibleToBool, _ConvertibleToFloat
from openpyxl.descriptors.excel import ExtensionList
from openpyxl.descriptors.nested import NestedBool, NestedMinMax, NestedNoneSet, _HasTagAndGet, _NestedNoneSetParam
from openpyxl.descriptors.nested import NestedBool, NestedMinMax, NestedNoneSet, _NestedNoneSetParam

from ..xml._functions_overloads import _HasTagAndGet
from ._chart import ChartBase

_BubbleChartSizeRepresents: TypeAlias = Literal["area", "w"]
Expand Down
4 changes: 3 additions & 1 deletion stubs/openpyxl/openpyxl/chart/chartspace.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ from openpyxl.chart.text import RichText
from openpyxl.chart.title import Title
from openpyxl.descriptors.base import Alias, String, Typed, _ConvertibleToBool, _ConvertibleToFloat
from openpyxl.descriptors.excel import ExtensionList
from openpyxl.descriptors.nested import NestedBool, NestedMinMax, NestedNoneSet, NestedString, _HasTagAndGet, _NestedNoneSetParam
from openpyxl.descriptors.nested import NestedBool, NestedMinMax, NestedNoneSet, NestedString, _NestedNoneSetParam
from openpyxl.descriptors.serialisable import Serialisable
from openpyxl.drawing.colors import ColorMapping

from ..xml._functions_overloads import _HasTagAndGet

_ChartContainerDispBlanksAs: TypeAlias = Literal["span", "gap", "zero"]

class ChartContainer(Serialisable):
Expand Down
4 changes: 3 additions & 1 deletion stubs/openpyxl/openpyxl/chart/data_source.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ from typing_extensions import Literal
from openpyxl.descriptors import Strict
from openpyxl.descriptors.base import Alias, Bool, Integer, String, Typed, _ConvertibleToBool, _ConvertibleToInt
from openpyxl.descriptors.excel import ExtensionList
from openpyxl.descriptors.nested import NestedInteger, NestedText, _HasTagAndGet
from openpyxl.descriptors.nested import NestedInteger, NestedText
from openpyxl.descriptors.serialisable import Serialisable

from ..xml._functions_overloads import _HasTagAndGet

class NumFmt(Serialisable):
formatCode: String[Literal[False]]
sourceLinked: Bool[Literal[False]]
Expand Down
4 changes: 3 additions & 1 deletion stubs/openpyxl/openpyxl/chart/error_bar.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ from openpyxl.chart.data_source import NumDataSource
from openpyxl.chart.shapes import GraphicalProperties
from openpyxl.descriptors.base import Alias, Typed, _ConvertibleToBool, _ConvertibleToFloat
from openpyxl.descriptors.excel import ExtensionList
from openpyxl.descriptors.nested import NestedBool, NestedFloat, NestedNoneSet, NestedSet, _HasTagAndGet, _NestedNoneSetParam
from openpyxl.descriptors.nested import NestedBool, NestedFloat, NestedNoneSet, NestedSet, _NestedNoneSetParam
from openpyxl.descriptors.serialisable import Serialisable

from ..xml._functions_overloads import _HasTagAndGet

_ErrorBarsErrBarType: TypeAlias = Literal["both", "minus", "plus"]
_ErrorBarsErrValType: TypeAlias = Literal["cust", "fixedVal", "percentage", "stdDev", "stdErr"]
_ErrorBarsErrDir: TypeAlias = Literal["x", "y"]
Expand Down
4 changes: 3 additions & 1 deletion stubs/openpyxl/openpyxl/chart/label.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ from openpyxl.chart.shapes import GraphicalProperties
from openpyxl.chart.text import RichText
from openpyxl.descriptors.base import Alias, Typed, _ConvertibleToBool, _ConvertibleToInt
from openpyxl.descriptors.excel import ExtensionList
from openpyxl.descriptors.nested import NestedBool, NestedInteger, NestedNoneSet, NestedString, _HasTagAndGet, _NestedNoneSetParam
from openpyxl.descriptors.nested import NestedBool, NestedInteger, NestedNoneSet, NestedString, _NestedNoneSetParam
from openpyxl.descriptors.serialisable import Serialisable as Serialisable

from ..xml._functions_overloads import _HasTagAndGet

_DataLabelBaseDLblPos: TypeAlias = Literal["bestFit", "b", "ctr", "inBase", "inEnd", "l", "outEnd", "r", "t"]

class _DataLabelBase(Serialisable):
Expand Down
4 changes: 3 additions & 1 deletion stubs/openpyxl/openpyxl/chart/layout.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ from typing_extensions import Literal, TypeAlias

from openpyxl.descriptors.base import Alias, Typed, _ConvertibleToFloat
from openpyxl.descriptors.excel import ExtensionList
from openpyxl.descriptors.nested import NestedMinMax, NestedNoneSet, NestedSet, _HasTagAndGet, _NestedNoneSetParam
from openpyxl.descriptors.nested import NestedMinMax, NestedNoneSet, NestedSet, _NestedNoneSetParam
from openpyxl.descriptors.serialisable import Serialisable

from ..xml._functions_overloads import _HasTagAndGet

_ManualLayoutMode: TypeAlias = Literal["edge", "factor"]
_ManualLayoutLayoutTarget: TypeAlias = Literal["inner", "outer"]

Expand Down
4 changes: 3 additions & 1 deletion stubs/openpyxl/openpyxl/chart/legend.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ from openpyxl.chart.shapes import GraphicalProperties
from openpyxl.chart.text import RichText
from openpyxl.descriptors.base import Alias, Typed, _ConvertibleToBool, _ConvertibleToInt
from openpyxl.descriptors.excel import ExtensionList
from openpyxl.descriptors.nested import NestedBool, NestedInteger, NestedSet, _HasTagAndGet
from openpyxl.descriptors.nested import NestedBool, NestedInteger, NestedSet
from openpyxl.descriptors.serialisable import Serialisable

from ..xml._functions_overloads import _HasTagAndGet

_LegendLegendPos: TypeAlias = Literal["b", "tr", "l", "r", "t"]

class LegendEntry(Serialisable):
Expand Down
3 changes: 2 additions & 1 deletion stubs/openpyxl/openpyxl/chart/line_chart.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ from openpyxl.chart.label import DataLabelList
from openpyxl.chart.updown_bars import UpDownBars
from openpyxl.descriptors.base import Alias, Typed, _ConvertibleToBool
from openpyxl.descriptors.excel import ExtensionList
from openpyxl.descriptors.nested import NestedBool, NestedSet, _HasTagAndGet
from openpyxl.descriptors.nested import NestedBool, NestedSet

from ..xml._functions_overloads import _HasTagAndGet
from ._chart import ChartBase

_LineChartBaseGrouping: TypeAlias = Literal["percentStacked", "standard", "stacked"]
Expand Down
4 changes: 3 additions & 1 deletion stubs/openpyxl/openpyxl/chart/marker.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ from openpyxl.chart.picture import PictureOptions
from openpyxl.chart.shapes import GraphicalProperties
from openpyxl.descriptors.base import Alias, Typed, _ConvertibleToBool, _ConvertibleToFloat, _ConvertibleToInt
from openpyxl.descriptors.excel import ExtensionList
from openpyxl.descriptors.nested import NestedBool, NestedInteger, NestedMinMax, NestedNoneSet, _HasTagAndGet, _NestedNoneSetParam
from openpyxl.descriptors.nested import NestedBool, NestedInteger, NestedMinMax, NestedNoneSet, _NestedNoneSetParam
from openpyxl.descriptors.serialisable import Serialisable

from ..xml._functions_overloads import _HasTagAndGet

_MarkerSymbol: TypeAlias = Literal[
"circle", "dash", "diamond", "dot", "picture", "plus", "square", "star", "triangle", "x", "auto"
]
Expand Down
4 changes: 3 additions & 1 deletion stubs/openpyxl/openpyxl/chart/picture.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ from typing import ClassVar
from typing_extensions import Literal, TypeAlias

from openpyxl.descriptors.base import _ConvertibleToBool, _ConvertibleToFloat
from openpyxl.descriptors.nested import NestedBool, NestedFloat, NestedNoneSet, _HasTagAndGet, _NestedNoneSetParam
from openpyxl.descriptors.nested import NestedBool, NestedFloat, NestedNoneSet, _NestedNoneSetParam
from openpyxl.descriptors.serialisable import Serialisable

from ..xml._functions_overloads import _HasTagAndGet

_PictureOptionsPictureFormat: TypeAlias = Literal["stretch", "stack", "stackScale"]

class PictureOptions(Serialisable):
Expand Down
11 changes: 2 additions & 9 deletions stubs/openpyxl/openpyxl/chart/pie_chart.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,10 @@ from openpyxl.chart.axis import ChartLines
from openpyxl.chart.label import DataLabelList
from openpyxl.descriptors.base import Alias, Typed, _ConvertibleToBool, _ConvertibleToFloat
from openpyxl.descriptors.excel import ExtensionList
from openpyxl.descriptors.nested import (
NestedBool,
NestedFloat,
NestedMinMax,
NestedNoneSet,
NestedSet,
_HasTagAndGet,
_NestedNoneSetParam,
)
from openpyxl.descriptors.nested import NestedBool, NestedFloat, NestedMinMax, NestedNoneSet, NestedSet, _NestedNoneSetParam
from openpyxl.descriptors.serialisable import Serialisable

from ..xml._functions_overloads import _HasTagAndGet
from ._chart import ChartBase

_ProjectedPieChartOfPieType: TypeAlias = Literal["pie", "bar"]
Expand Down
4 changes: 3 additions & 1 deletion stubs/openpyxl/openpyxl/chart/pivot.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ from openpyxl.chart.shapes import GraphicalProperties
from openpyxl.chart.text import RichText
from openpyxl.descriptors.base import Alias, Typed, _ConvertibleToInt
from openpyxl.descriptors.excel import ExtensionList
from openpyxl.descriptors.nested import NestedInteger, NestedText, _HasTagAndGet
from openpyxl.descriptors.nested import NestedInteger, NestedText
from openpyxl.descriptors.serialisable import Serialisable

from ..xml._functions_overloads import _HasTagAndGet

class PivotSource(Serialisable):
tagname: ClassVar[str]
name: NestedText[str, Literal[False]]
Expand Down
4 changes: 3 additions & 1 deletion stubs/openpyxl/openpyxl/chart/plotarea.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ 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, _HasTagAndGet
from openpyxl.descriptors.nested import NestedBool
from openpyxl.descriptors.serialisable import Serialisable

from ..xml._functions_overloads import _HasTagAndGet

class DataTable(Serialisable):
tagname: ClassVar[str]
showHorzBorder: NestedBool[Literal[True]]
Expand Down
3 changes: 2 additions & 1 deletion stubs/openpyxl/openpyxl/chart/radar_chart.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ from openpyxl.chart.axis import NumericAxis, TextAxis
from openpyxl.chart.label import DataLabelList
from openpyxl.descriptors.base import Alias, Typed, _ConvertibleToBool
from openpyxl.descriptors.excel import ExtensionList
from openpyxl.descriptors.nested import NestedBool, NestedSet, _HasTagAndGet
from openpyxl.descriptors.nested import NestedBool, NestedSet

from ..xml._functions_overloads import _HasTagAndGet
from ._chart import ChartBase

_RadarChartRadarStyle: TypeAlias = Literal["standard", "marker", "filled"]
Expand Down
3 changes: 2 additions & 1 deletion stubs/openpyxl/openpyxl/chart/scatter_chart.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ from openpyxl.chart.axis import NumericAxis, TextAxis
from openpyxl.chart.label import DataLabelList
from openpyxl.descriptors.base import Alias, Typed, _ConvertibleToBool
from openpyxl.descriptors.excel import ExtensionList
from openpyxl.descriptors.nested import NestedBool, NestedNoneSet, _HasTagAndGet, _NestedNoneSetParam
from openpyxl.descriptors.nested import NestedBool, NestedNoneSet, _NestedNoneSetParam

from ..xml._functions_overloads import _HasTagAndGet
from ._chart import ChartBase as ChartBase

_ScatterChartScatterStyle: TypeAlias = Literal["line", "lineMarker", "marker", "smooth", "smoothMarker"]
Expand Down
4 changes: 3 additions & 1 deletion stubs/openpyxl/openpyxl/chart/series.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ from openpyxl.chart.shapes import GraphicalProperties
from openpyxl.chart.trendline import Trendline
from openpyxl.descriptors.base import Alias, Typed, _ConvertibleToBool, _ConvertibleToInt
from openpyxl.descriptors.excel import ExtensionList
from openpyxl.descriptors.nested import NestedBool, NestedInteger, NestedNoneSet, NestedText, _HasTagAndGet, _NestedNoneSetParam
from openpyxl.descriptors.nested import NestedBool, NestedInteger, NestedNoneSet, NestedText, _NestedNoneSetParam
from openpyxl.descriptors.serialisable import Serialisable

from ..xml._functions_overloads import _HasTagAndGet

_SeriesShape: TypeAlias = Literal["cone", "coneToMax", "box", "cylinder", "pyramid", "pyramidToMax"]

attribute_mapping: Incomplete
Expand Down
4 changes: 3 additions & 1 deletion stubs/openpyxl/openpyxl/chart/shapes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ from typing import ClassVar
from typing_extensions import Literal, TypeAlias

from openpyxl.descriptors.base import Alias, NoneSet, Typed, _ConvertibleToBool
from openpyxl.descriptors.nested import EmptyTag, _HasTagAndGet
from openpyxl.descriptors.nested import EmptyTag
from openpyxl.descriptors.serialisable import Serialisable
from openpyxl.drawing.fill import GradientFillProperties, PatternFillProperties
from openpyxl.drawing.geometry import CustomGeometry2D, PresetGeometry2D, Scene3D, Shape3D, Transform2D
from openpyxl.drawing.line import LineProperties

from ..xml._functions_overloads import _HasTagAndGet

_GraphicalPropertiesBwMode: TypeAlias = Literal[
"clr", "auto", "gray", "ltGray", "invGray", "grayWhite", "blackGray", "blackWhite", "black", "white", "hidden"
]
Expand Down
3 changes: 2 additions & 1 deletion stubs/openpyxl/openpyxl/chart/surface_chart.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ from openpyxl.chart.axis import NumericAxis, SeriesAxis, TextAxis
from openpyxl.chart.shapes import GraphicalProperties
from openpyxl.descriptors.base import Alias, Typed, _ConvertibleToBool, _ConvertibleToInt
from openpyxl.descriptors.excel import ExtensionList
from openpyxl.descriptors.nested import NestedBool, NestedInteger, _HasTagAndGet
from openpyxl.descriptors.nested import NestedBool, NestedInteger
from openpyxl.descriptors.serialisable import Serialisable

from ..xml._functions_overloads import _HasTagAndGet
from ._3d import _3DBase
from ._chart import ChartBase

Expand Down
4 changes: 3 additions & 1 deletion stubs/openpyxl/openpyxl/chart/title.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ from openpyxl.chart.text import RichText, Text
from openpyxl.descriptors import Strict, Typed
from openpyxl.descriptors.base import Alias, _ConvertibleToBool
from openpyxl.descriptors.excel import ExtensionList
from openpyxl.descriptors.nested import NestedBool, _HasTagAndGet
from openpyxl.descriptors.nested import NestedBool
from openpyxl.descriptors.serialisable import Serialisable

from ..xml._functions_overloads import _HasTagAndGet

class Title(Serialisable):
tagname: ClassVar[str]
tx: Typed[Text, Literal[True]]
Expand Down
4 changes: 3 additions & 1 deletion stubs/openpyxl/openpyxl/chart/trendline.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ from openpyxl.chart.shapes import GraphicalProperties
from openpyxl.chart.text import RichText, Text
from openpyxl.descriptors.base import Alias, String, Typed, _ConvertibleToBool, _ConvertibleToFloat, _ConvertibleToInt
from openpyxl.descriptors.excel import ExtensionList
from openpyxl.descriptors.nested import NestedBool, NestedFloat, NestedInteger, NestedSet, _HasTagAndGet
from openpyxl.descriptors.nested import NestedBool, NestedFloat, NestedInteger, NestedSet
from openpyxl.descriptors.serialisable import Serialisable

from ..xml._functions_overloads import _HasTagAndGet

_TrendlineTrendlineType: TypeAlias = Literal["exp", "linear", "log", "movingAvg", "poly", "power"]

class TrendlineLabel(Serialisable):
Expand Down
13 changes: 10 additions & 3 deletions stubs/openpyxl/openpyxl/comments/shape_writer.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
from _typeshed import Incomplete
from typing import Any
from typing_extensions import TypeAlias

from ..xml._functions_overloads import _lxml_Element, _ParentElement

_RootElement: TypeAlias = _ParentElement[Any] | _lxml_Element

vmlns: str
officens: str
Expand All @@ -9,6 +15,7 @@ class ShapeWriter:
vml_path: Incomplete
comments: Incomplete
def __init__(self, comments) -> None: ...
def add_comment_shapetype(self, root) -> None: ...
def add_comment_shape(self, root, idx, coord, height, width) -> None: ...
def write(self, root): ...
def add_comment_shapetype(self, root: _RootElement) -> None: ...
def add_comment_shape(self, root: _RootElement, idx, coord, height, width) -> None: ...
# Any object missing "findall" is replaced by an Element
def write(self, root: _RootElement | None) -> str: ...
16 changes: 3 additions & 13 deletions stubs/openpyxl/openpyxl/descriptors/nested.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from _typeshed import Incomplete, Unused
from collections.abc import Callable, Iterable
from typing import Any, ClassVar, NoReturn, Protocol, TypeVar, overload
from collections.abc import Iterable
from typing import Any, ClassVar, NoReturn, overload
from typing_extensions import Literal, TypeAlias

from openpyxl.descriptors import Strict
Expand All @@ -9,19 +9,9 @@ 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 .base import _M, _N, _T, _ConvertibleToBool, _ConvertibleToFloat, _ConvertibleToInt, _ExpectedTypeParam

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

# Usually an Element() from either lxml or xml.etree (has a 'tag' element)
class _HasTagAndGet(Protocol[_T_co]):
tag: Any # str | None | Callable[..., Any]
def get(self, __value: str) -> _T_co | None: ...

class _HasTagAndText(Protocol):
tag: str | Callable[..., Any]
text: str

_NestedNoneSetParam: TypeAlias = _HasTagAndGet[_T | Literal["none"] | None] | _T | Literal["none"] | None

# NOTE: type: ignore[misc]: Class does not reimplement the relevant methods, so runtime also has incompatible supertypes
Expand Down
Loading