Skip to content

Commit

Permalink
openpyxl: type tagname, namespace and __doc__ ClassVar and pa…
Browse files Browse the repository at this point in the history
…rams (python#10308)
  • Loading branch information
Avasam authored Jun 14, 2023
1 parent 8e4595a commit 8624edd
Show file tree
Hide file tree
Showing 111 changed files with 440 additions and 454 deletions.
10 changes: 5 additions & 5 deletions stubs/openpyxl/@tests/test_cases/check_nested_descriptors.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
# These tests are essentially a mirror of check_base_descriptors
from __future__ import annotations

from typing import Any, Union, cast
from typing import Union, cast
from typing_extensions import Literal, assert_type

from openpyxl.descriptors import Strict
from openpyxl.descriptors.nested import ( # EmptyTag,
from openpyxl.descriptors.nested import (
EmptyTag,
Nested,
NestedBool,
Expand All @@ -32,7 +32,7 @@


class WithDescriptors(Serialisable):
descriptor = Nested[str]()
descriptor = Nested(expected_type=str)

set_tuple = NestedSet(values=("a", 1, 0.0))
set_list = NestedSet(values=["a", 1, 0.0])
Expand Down Expand Up @@ -130,15 +130,15 @@ class WithDescriptors(Serialisable):

# Test with missing subclass
class NotSerialisable:
descriptor = Nested[Any]()
descriptor = Nested(expected_type=object)


NotSerialisable().descriptor = None # type: ignore


# Test with Strict subclass
class WithDescriptorsStrict(Strict):
descriptor = Nested[Any]()
descriptor = Nested(expected_type=object)


WithDescriptorsStrict().descriptor = None
Expand Down
10 changes: 5 additions & 5 deletions stubs/openpyxl/openpyxl/cell/text.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ _PhoneticPropertiesType: TypeAlias = Literal["halfwidthKatakana", "fullwidthKata
_PhoneticPropertiesAlignment: TypeAlias = Literal["noControl", "left", "center", "distributed"]

class PhoneticProperties(Serialisable):
tagname: str
tagname: ClassVar[str]
fontId: Integer[Literal[False]]
type: NoneSet[_PhoneticPropertiesType]
alignment: NoneSet[_PhoneticPropertiesAlignment]
Expand All @@ -25,15 +25,15 @@ class PhoneticProperties(Serialisable):
_PhoneticProperties: TypeAlias = PhoneticProperties

class PhoneticText(Serialisable):
tagname: str
tagname: ClassVar[str]
sb: Integer[Literal[False]]
eb: Integer[Literal[False]]
t: NestedText[str, Literal[False]]
text: Alias
def __init__(self, sb: _ConvertibleToInt, eb: _ConvertibleToInt, t: object = None) -> None: ...

class InlineFont(Font):
tagname: str
tagname: ClassVar[str]
rFont: NestedString[Literal[True]]
charset: Incomplete
family: Incomplete
Expand Down Expand Up @@ -70,7 +70,7 @@ class InlineFont(Font):
) -> None: ...

class RichText(Serialisable):
tagname: str
tagname: ClassVar[str]
rPr: Typed[InlineFont, Literal[True]]
font: Alias
t: NestedText[str, Literal[True]]
Expand All @@ -79,7 +79,7 @@ class RichText(Serialisable):
def __init__(self, rPr: InlineFont | None = None, t: object = None) -> None: ...

class Text(Serialisable):
tagname: str
tagname: ClassVar[str]
t: NestedText[str, Literal[True]]
plain: Alias
r: Incomplete
Expand Down
6 changes: 3 additions & 3 deletions stubs/openpyxl/openpyxl/chart/_3d.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ from openpyxl.descriptors.nested import NestedBool, NestedInteger, NestedMinMax,
from openpyxl.descriptors.serialisable import Serialisable

class View3D(Serialisable):
tagname: str
tagname: ClassVar[str]
rotX: NestedMinMax[float, Literal[True]]
x_rotation: Alias
hPercent: NestedMinMax[float, Literal[True]]
Expand All @@ -35,7 +35,7 @@ class View3D(Serialisable):
) -> None: ...

class Surface(Serialisable):
tagname: str
tagname: ClassVar[str]
thickness: NestedInteger[Literal[True]]
spPr: Typed[GraphicalProperties, Literal[True]]
graphicalProperties: Alias
Expand All @@ -51,7 +51,7 @@ class Surface(Serialisable):
) -> None: ...

class _3DBase(Serialisable):
tagname: str
tagname: ClassVar[str]
view3D: Typed[View3D, Literal[True]]
floor: Typed[Surface, Literal[True]]
sideWall: Typed[Surface, Literal[True]]
Expand Down
6 changes: 1 addition & 5 deletions stubs/openpyxl/openpyxl/chart/_chart.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from _typeshed import Incomplete, Unused
from abc import abstractmethod
from typing import ClassVar
from typing_extensions import Literal, TypeAlias

Expand Down Expand Up @@ -41,12 +40,9 @@ class ChartBase(Serialisable):
def __init__(self, axId=(), **kw: Unused) -> None: ...
def __hash__(self) -> int: ...
def __iadd__(self, other): ...
def to_tree(self, namespace: Incomplete | None = None, tagname: Incomplete | None = None, idx: Incomplete | None = None): ... # type: ignore[override]
def to_tree(self, namespace: str | None = None, tagname: str | None = None, idx: Incomplete | None = None): ... # type: ignore[override]
def set_categories(self, labels) -> None: ...
def add_data(self, data, from_rows: bool = False, titles_from_data: bool = False) -> None: ...
def append(self, value) -> None: ...
@property
def path(self): ...
@property
@abstractmethod
def tagname(self) -> str: ...
8 changes: 2 additions & 6 deletions stubs/openpyxl/openpyxl/chart/area_chart.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from _typeshed import Incomplete, Unused
from abc import abstractmethod
from typing import ClassVar
from typing_extensions import Literal, TypeAlias

Expand Down Expand Up @@ -29,12 +28,9 @@ class _AreaChartBase(ChartBase):
dLbls: DataLabelList | None = None,
dropLines: ChartLines | None = None,
) -> None: ...
@property
@abstractmethod
def tagname(self) -> str: ...

class AreaChart(_AreaChartBase):
tagname: str
tagname: ClassVar[str]
grouping: Incomplete
varyColors: Incomplete
ser: Incomplete
Expand All @@ -47,7 +43,7 @@ class AreaChart(_AreaChartBase):
def __init__(self, axId: Unused = None, extLst: Unused = None, **kw) -> None: ...

class AreaChart3D(AreaChart):
tagname: str
tagname: ClassVar[str]
grouping: Incomplete
varyColors: Incomplete
ser: Incomplete
Expand Down
20 changes: 8 additions & 12 deletions stubs/openpyxl/openpyxl/chart/axis.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from _typeshed import Incomplete, Unused
from abc import abstractmethod
from typing import ClassVar, overload
from typing_extensions import Literal, TypeAlias

Expand Down Expand Up @@ -41,13 +40,13 @@ _TextAxisLblAlgn: TypeAlias = Literal["ctr", "l", "r"]
_DateAxisTimeUnit: TypeAlias = Literal["days", "months", "years"]

class ChartLines(Serialisable):
tagname: str
tagname: ClassVar[str]
spPr: Typed[GraphicalProperties, Literal[True]]
graphicalProperties: Alias
def __init__(self, spPr: GraphicalProperties | None = None) -> None: ...

class Scaling(Serialisable):
tagname: str
tagname: ClassVar[str]
logBase: NestedFloat[Literal[True]]
orientation: NestedSet[_ScalingOrientation]
max: NestedFloat[Literal[True]]
Expand Down Expand Up @@ -125,12 +124,9 @@ class _BaseAxis(Serialisable):
crosses: Incomplete | None = None,
crossesAt: _HasTagAndGet[_ConvertibleToFloat | None] | _ConvertibleToFloat | None = None,
) -> None: ...
@property
@abstractmethod
def tagname(self) -> str: ...

class DisplayUnitsLabel(Serialisable):
tagname: str
tagname: ClassVar[str]
layout: Typed[Layout, Literal[True]]
tx: Typed[Text, Literal[True]]
text: Alias
Expand All @@ -148,7 +144,7 @@ class DisplayUnitsLabel(Serialisable):
) -> None: ...

class DisplayUnitsLabelList(Serialisable):
tagname: str
tagname: ClassVar[str]
custUnit: NestedFloat[Literal[True]]
builtInUnit: NestedNoneSet[_DisplayUnitsLabelListBuiltInUnit]
dispUnitsLbl: Typed[DisplayUnitsLabel, Literal[True]]
Expand All @@ -166,7 +162,7 @@ class DisplayUnitsLabelList(Serialisable):
) -> None: ...

class NumericAxis(_BaseAxis):
tagname: str
tagname: ClassVar[str]
axId: Incomplete
scaling: Incomplete
delete: Incomplete
Expand Down Expand Up @@ -202,7 +198,7 @@ class NumericAxis(_BaseAxis):
def from_tree(cls, node): ...

class TextAxis(_BaseAxis):
tagname: str
tagname: ClassVar[str]
axId: Incomplete
scaling: Incomplete
delete: Incomplete
Expand Down Expand Up @@ -240,7 +236,7 @@ class TextAxis(_BaseAxis):
) -> None: ...

class DateAxis(TextAxis):
tagname: str
tagname: ClassVar[str]
axId: Incomplete
scaling: Incomplete
delete: Incomplete
Expand Down Expand Up @@ -280,7 +276,7 @@ class DateAxis(TextAxis):
) -> None: ...

class SeriesAxis(_BaseAxis):
tagname: str
tagname: ClassVar[str]
axId: Incomplete
scaling: Incomplete
delete: Incomplete
Expand Down
8 changes: 2 additions & 6 deletions stubs/openpyxl/openpyxl/chart/bar_chart.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from _typeshed import Incomplete, Unused
from abc import abstractmethod
from typing import ClassVar
from typing_extensions import Literal, TypeAlias

Expand Down Expand Up @@ -34,12 +33,9 @@ class _BarChartBase(ChartBase):
dLbls: DataLabelList | None = None,
**kw,
) -> None: ...
@property
@abstractmethod
def tagname(self) -> str: ...

class BarChart(_BarChartBase):
tagname: str
tagname: ClassVar[str]
barDir: Incomplete
grouping: Incomplete
varyColors: Incomplete
Expand All @@ -63,7 +59,7 @@ class BarChart(_BarChartBase):
) -> None: ...

class BarChart3D(_BarChartBase, _3DBase):
tagname: str
tagname: ClassVar[str]
barDir: Incomplete
grouping: Incomplete
varyColors: Incomplete
Expand Down
2 changes: 1 addition & 1 deletion stubs/openpyxl/openpyxl/chart/bubble_chart.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ from ._chart import ChartBase
_BubbleChartSizeRepresents: TypeAlias = Literal["area", "w"]

class BubbleChart(ChartBase):
tagname: str
tagname: ClassVar[str]
varyColors: NestedBool[Literal[True]]
ser: Incomplete
dLbls: Typed[DataLabelList, Literal[True]]
Expand Down
10 changes: 5 additions & 5 deletions stubs/openpyxl/openpyxl/chart/chartspace.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ from openpyxl.drawing.colors import ColorMapping
_ChartContainerDispBlanksAs: TypeAlias = Literal["span", "gap", "zero"]

class ChartContainer(Serialisable):
tagname: str
tagname: ClassVar[str]
title: Typed[Title, Literal[True]]
autoTitleDeleted: NestedBool[Literal[True]]
pivotFmts: Incomplete
Expand Down Expand Up @@ -51,7 +51,7 @@ class ChartContainer(Serialisable):
) -> None: ...

class Protection(Serialisable):
tagname: str
tagname: ClassVar[str]
chartObject: NestedBool[Literal[True]]
data: NestedBool[Literal[True]]
formatting: NestedBool[Literal[True]]
Expand All @@ -68,7 +68,7 @@ class Protection(Serialisable):
) -> None: ...

class ExternalData(Serialisable):
tagname: str
tagname: ClassVar[str]
autoUpdate: NestedBool[Literal[True]]
id: String[Literal[False]]
@overload
Expand All @@ -79,7 +79,7 @@ class ExternalData(Serialisable):
def __init__(self, autoUpdate: Incomplete | None, id: str) -> None: ...

class ChartSpace(Serialisable):
tagname: str
tagname: ClassVar[str]
date1904: NestedBool[Literal[True]]
lang: NestedString[Literal[True]]
roundedCorners: NestedBool[Literal[True]]
Expand Down Expand Up @@ -134,4 +134,4 @@ class ChartSpace(Serialisable):
userShapes: Incomplete | None = None,
extLst: Unused = None,
) -> None: ...
def to_tree(self, tagname: Incomplete | None = None, idx: Incomplete | None = None, namespace: Incomplete | None = None): ...
def to_tree(self, tagname: Incomplete | None = None, idx: Incomplete | None = None, namespace: str | None = None): ...
14 changes: 7 additions & 7 deletions stubs/openpyxl/openpyxl/chart/data_source.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ class NumRef(Serialisable):
def __init__(self, f: object = None, numCache: NumData | None = None, extLst: Unused = None) -> None: ...

class StrVal(Serialisable):
tagname: str
tagname: ClassVar[str]
idx: Integer[Literal[False]]
v: NestedText[str, Literal[False]]
def __init__(self, idx: _ConvertibleToInt = 0, v: object = None) -> None: ...

class StrData(Serialisable):
tagname: str
tagname: ClassVar[str]
ptCount: NestedInteger[Literal[True]]
pt: Incomplete
extLst: Typed[ExtensionList, Literal[True]]
Expand All @@ -63,7 +63,7 @@ class StrData(Serialisable):
) -> None: ...

class StrRef(Serialisable):
tagname: str
tagname: ClassVar[str]
f: NestedText[str, Literal[True]]
strCache: Typed[StrData, Literal[True]]
extLst: Typed[ExtensionList, Literal[True]]
Expand All @@ -76,29 +76,29 @@ class NumDataSource(Serialisable):
def __init__(self, numRef: NumRef | None = None, numLit: NumData | None = None) -> None: ...

class Level(Serialisable):
tagname: str
tagname: ClassVar[str]
pt: Incomplete
__elements__: ClassVar[tuple[str, ...]]
def __init__(self, pt=()) -> None: ...

class MultiLevelStrData(Serialisable):
tagname: str
tagname: ClassVar[str]
ptCount: Integer[Literal[True]]
lvl: Incomplete
extLst: Typed[ExtensionList, Literal[True]]
__elements__: ClassVar[tuple[str, ...]]
def __init__(self, ptCount: _ConvertibleToInt | None = None, lvl=(), extLst: Unused = None) -> None: ...

class MultiLevelStrRef(Serialisable):
tagname: str
tagname: ClassVar[str]
f: NestedText[str, Literal[False]]
multiLvlStrCache: Typed[MultiLevelStrData, Literal[True]]
extLst: Typed[ExtensionList, Literal[True]]
__elements__: ClassVar[tuple[str, ...]]
def __init__(self, f: object = None, multiLvlStrCache: MultiLevelStrData | None = None, extLst: Unused = None) -> None: ...

class AxDataSource(Serialisable):
tagname: str
tagname: ClassVar[str]
numRef: Typed[NumRef, Literal[True]]
numLit: Typed[NumData, Literal[True]]
strRef: Typed[StrRef, Literal[True]]
Expand Down
2 changes: 1 addition & 1 deletion stubs/openpyxl/openpyxl/chart/error_bar.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ _ErrorBarsErrValType: TypeAlias = Literal["cust", "fixedVal", "percentage", "std
_ErrorBarsErrDir: TypeAlias = Literal["x", "y"]

class ErrorBars(Serialisable):
tagname: str
tagname: ClassVar[str]
errDir: NestedNoneSet[_ErrorBarsErrDir]
direction: Alias
errBarType: NestedSet[_ErrorBarsErrBarType]
Expand Down
Loading

0 comments on commit 8624edd

Please sign in to comment.