diff --git a/stubs/openpyxl/@tests/stubtest_allowlist.txt b/stubs/openpyxl/@tests/stubtest_allowlist.txt index 199b32567..6a4840f16 100644 --- a/stubs/openpyxl/@tests/stubtest_allowlist.txt +++ b/stubs/openpyxl/@tests/stubtest_allowlist.txt @@ -31,13 +31,15 @@ openpyxl\.descriptors\.(base\.)?Typed\.allow_none # "has a default value but stub argument does not" # Runtime has default arguments that would fail - openpyxl.cell.text.PhoneticProperties.__init__ openpyxl.cell.text.PhoneticText.__init__ +openpyxl.chart.axis._BaseAxis.__init__ openpyxl.chart.chartspace.ChartSpace.__init__ openpyxl.chart.chartspace.ExternalData.__init__ openpyxl.chart.data_source.NumFmt.__init__ openpyxl.chart.data_source.NumVal.__init__ +openpyxl.chart.marker.DataPoint.__init__ +openpyxl.chart.pivot.PivotSource.__init__ openpyxl.chartsheet.custom.CustomChartsheetView.__init__ openpyxl.chartsheet.publish.WebPublishItem.__init__ openpyxl.comments.comment_sheet.CommentSheet.__init__ diff --git a/stubs/openpyxl/@tests/test_cases/check_base_descriptors.py b/stubs/openpyxl/@tests/test_cases/check_base_descriptors.py index d9a950c5b..16973dbfc 100644 --- a/stubs/openpyxl/@tests/test_cases/check_base_descriptors.py +++ b/stubs/openpyxl/@tests/test_cases/check_base_descriptors.py @@ -216,7 +216,7 @@ with_descriptors.typed_none = None with_descriptors.typed_none = 0 # type: ignore -# NOTE: Can't check Set for literal int wen used with a float because any int is a vlaid float +# NOTE: Can't check Set for literal int wen used with a float because any int is a valid float with_descriptors.set_tuple = "a" with_descriptors.set_tuple = 0 with_descriptors.set_tuple = 0.0 @@ -295,7 +295,7 @@ with_descriptors.convertible_not_none = object() # pyright: ignore[reportGenera with_descriptors.convertible_none = 0 with_descriptors.convertible_none = "0" with_descriptors.convertible_none = None -with_descriptors.convertible_none = object() # FIXME: False positive(?) in pyright and mypy +with_descriptors.convertible_none = object() # FIXME: False negative(?) in pyright and mypy with_descriptors.minmax_float = 0 @@ -374,7 +374,7 @@ with_descriptors.float_none = 0.0 with_descriptors.float_none = "0" with_descriptors.float_none = b"0" with_descriptors.float_none = None -with_descriptors.float_none = object() # FIXME: False positive(?) in pyright and mypy +with_descriptors.float_none = object() # FIXME: False negative(?) in pyright and mypy with_descriptors.integer_not_none = 0 @@ -389,4 +389,4 @@ with_descriptors.integer_none = 0.0 with_descriptors.integer_none = "0" with_descriptors.integer_none = b"0" with_descriptors.integer_none = None -with_descriptors.integer_none = object() # FIXME: False positive(?) in pyright and mypy +with_descriptors.integer_none = object() # FIXME: False negative(?) in pyright and mypy diff --git a/stubs/openpyxl/@tests/test_cases/check_nested_descriptors.py b/stubs/openpyxl/@tests/test_cases/check_nested_descriptors.py new file mode 100644 index 000000000..f4018c63f --- /dev/null +++ b/stubs/openpyxl/@tests/test_cases/check_nested_descriptors.py @@ -0,0 +1,466 @@ +# Needed until mypy issues are solved +# pyright: reportUnnecessaryTypeIgnoreComment=false + +# These tests are essentially a mirror of check_base_descriptors +from __future__ import annotations + +from typing import Any, Union, cast +from typing_extensions import Literal, assert_type + +from openpyxl.descriptors import Strict +from openpyxl.descriptors.nested import ( # EmptyTag, + EmptyTag, + Nested, + NestedBool, + NestedFloat, + NestedInteger, + NestedMinMax, + NestedNoneSet, + NestedSet, + NestedString, + NestedText, + NestedValue, + _HasTagAndGet, +) +from openpyxl.descriptors.serialisable import Serialisable +from openpyxl.xml.functions import Element + +_ = object() # More concise discard object for casts + +# Ensure the default "Element" matches the _HasTagAndGet protocol +element: _HasTagAndGet[str] = Element("") + + +class WithDescriptors(Serialisable): + descriptor = Nested[str]() + + set_tuple = NestedSet(values=("a", 1, 0.0)) + set_list = NestedSet(values=["a", 1, 0.0]) + set_tuple_none = NestedSet(values=("a", 1, 0.0, None)) + + noneset_tuple = NestedNoneSet(values=("a", 1, 0.0)) + noneset_list = NestedNoneSet(values=["a", 1, 0.0]) + + convertible_default = NestedValue(expected_type=int) + convertible_not_none = NestedValue(expected_type=int, allow_none=False) + convertible_none = NestedValue(expected_type=int, allow_none=True) + + text_default = NestedText(expected_type=str) + text_str_not_none = NestedText(expected_type=str, allow_none=False) + text_str_none = NestedText(expected_type=str, allow_none=True) + text_int_not_none = NestedText(expected_type=int, allow_none=False) + text_int_none = NestedText(expected_type=int, allow_none=True) + + # NOTE: min and max params are independent of expected_type since int and floats can always be compared together + minmax_default = NestedMinMax(min=0, max=0) + minmax_float = NestedMinMax(min=0, max=0, expected_type=float, allow_none=False) + minmax_float_none = NestedMinMax(min=0, max=0, expected_type=float, allow_none=True) + minmax_int = NestedMinMax(min=0.0, max=0.0, expected_type=int, allow_none=False) + minmax_int_none = NestedMinMax(min=0.0, max=0.0, expected_type=int, allow_none=True) + + bool_default = NestedBool() + bool_not_none = NestedBool(allow_none=False) + bool_none = NestedBool(allow_none=True) + + emptytag_default = EmptyTag() + emptytag_not_none = EmptyTag(allow_none=False) + emptytag_none = EmptyTag(allow_none=True) + + string_default = NestedString() + string_not_none = NestedString(allow_none=False) + string_none = NestedString(allow_none=True) + + float_default = NestedFloat() + float_not_none = NestedFloat(allow_none=False) + float_none = NestedFloat(allow_none=True) + + integer_default = NestedInteger() + integer_not_none = NestedInteger(allow_none=False) + integer_none = NestedInteger(allow_none=True) + + # Test inferred annotation + assert_type(descriptor, Nested[str]) + + assert_type(set_tuple, NestedSet[Union[Literal["a", 1], float]]) # type: ignore[assert-type] # False-positive in mypy + assert_type(set_list, NestedSet[Union[str, int, float]]) # type: ignore[assert-type] # False-positive in mypy # Literals are simplified in non-tuples + assert_type(set_tuple_none, NestedSet[Union[Literal["a", 1, None], float]]) # type: ignore[assert-type] # False-positive in mypy + + assert_type(noneset_tuple, NestedNoneSet[Union[Literal["a", 1], float]]) # type: ignore[assert-type] # False-positive in mypy + assert_type(noneset_list, NestedNoneSet[Union[str, float]]) # type: ignore[assert-type] # False-positive in mypy# int and float are merged in generic unions + + assert_type(convertible_default, NestedValue[int, Literal[False]]) + assert_type(convertible_not_none, NestedValue[int, Literal[False]]) + assert_type(convertible_none, NestedValue[int, Literal[True]]) + + assert_type(text_default, NestedText[str, Literal[False]]) + assert_type(text_str_not_none, NestedText[str, Literal[False]]) + assert_type(text_str_none, NestedText[str, Literal[True]]) + assert_type(text_int_not_none, NestedText[int, Literal[False]]) + assert_type(text_int_none, NestedText[int, Literal[True]]) + + assert_type(minmax_default, NestedMinMax[float, Literal[False]]) + assert_type(minmax_float, NestedMinMax[float, Literal[False]]) + assert_type(minmax_float_none, NestedMinMax[float, Literal[True]]) + assert_type(minmax_int, NestedMinMax[int, Literal[False]]) + assert_type(minmax_int_none, NestedMinMax[int, Literal[True]]) + + assert_type(bool_default, NestedBool[Literal[False]]) + assert_type(bool_not_none, NestedBool[Literal[False]]) + assert_type(bool_none, NestedBool[Literal[True]]) + + assert_type(emptytag_default, EmptyTag[Literal[False]]) + assert_type(emptytag_not_none, EmptyTag[Literal[False]]) + assert_type(emptytag_none, EmptyTag[Literal[True]]) + + assert_type(string_default, NestedString[Literal[False]]) + assert_type(string_not_none, NestedString[Literal[False]]) + assert_type(string_none, NestedString[Literal[True]]) + + assert_type(float_default, NestedFloat[Literal[False]]) + assert_type(float_not_none, NestedFloat[Literal[False]]) + assert_type(float_none, NestedFloat[Literal[True]]) + + assert_type(integer_default, NestedInteger[Literal[False]]) + assert_type(integer_not_none, NestedInteger[Literal[False]]) + assert_type(integer_none, NestedInteger[Literal[True]]) + + +with_descriptors = WithDescriptors() + + +# Test with missing subclass +class NotSerialisable: + descriptor = Nested[Any]() + + +NotSerialisable().descriptor = None # type: ignore + + +# Test with Strict subclass +class WithDescriptorsStrict(Strict): + descriptor = Nested[Any]() + + +WithDescriptorsStrict().descriptor = None + + +# Test getters +assert_type(with_descriptors.descriptor, str) + +assert_type(with_descriptors.set_tuple, Union[Literal["a", 1], float]) # type: ignore[assert-type] # False-positive in mypy +assert_type(with_descriptors.set_list, Union[str, int, float]) # type: ignore[assert-type] # False-positive in mypy # Literals are simplified in non-tuples +assert_type(with_descriptors.set_tuple_none, Union[Literal["a", 1, None], float]) # type: ignore[assert-type] # False-positive in mypy + +assert_type(with_descriptors.noneset_tuple, Union[Literal["a", 1], float, None]) # type: ignore[assert-type] # False-positive in mypy +assert_type(with_descriptors.noneset_list, Union[str, float, None]) # type: ignore[assert-type] # False-positive in mypy # int and float are merged in generic unions + +assert_type(with_descriptors.convertible_not_none, int) # type: ignore[assert-type] # False-positive in mypy +assert_type(with_descriptors.convertible_none, Union[int, None]) + +assert_type(with_descriptors.text_str_not_none, str) # type: ignore[assert-type] # False-positive in mypy +assert_type(with_descriptors.text_str_none, Union[str, None]) +assert_type(with_descriptors.text_int_not_none, int) # type: ignore[assert-type] # False-positive in mypy +assert_type(with_descriptors.text_int_none, Union[int, None]) + +assert_type(with_descriptors.minmax_float, float) # type: ignore[assert-type] # False-positive in mypy +assert_type(with_descriptors.minmax_float_none, Union[float, None]) +assert_type(with_descriptors.minmax_int, int) # type: ignore[assert-type] # False-positive in mypy +assert_type(with_descriptors.minmax_int_none, Union[int, None]) + +assert_type(with_descriptors.bool_not_none, bool) # type: ignore[assert-type] # False-positive in mypy +assert_type(with_descriptors.bool_none, Union[bool, None]) + +assert_type(with_descriptors.emptytag_not_none, bool) # type: ignore[assert-type] # False-positive in mypy +assert_type(with_descriptors.emptytag_none, Union[bool, None]) + +assert_type(with_descriptors.string_not_none, str) # type: ignore[assert-type] # False-positive in mypy +assert_type(with_descriptors.string_none, Union[str, None]) + +assert_type(with_descriptors.float_not_none, float) # type: ignore[assert-type] # False-positive in mypy +assert_type(with_descriptors.float_none, Union[float, None]) + +assert_type(with_descriptors.integer_not_none, int) # type: ignore[assert-type] # False-positive in mypy +assert_type(with_descriptors.integer_none, Union[int, None]) + + +# Test setters (expected type, None, unexpected type, Elements) +with_descriptors.descriptor = "" +with_descriptors.descriptor = None # type: ignore +with_descriptors.descriptor = 0 # type: ignore +with_descriptors.descriptor = cast(_HasTagAndGet[str], _) +with_descriptors.descriptor = cast(_HasTagAndGet[None], _) # type: ignore +with_descriptors.descriptor = cast(_HasTagAndGet[int], _) # type: ignore + + +# NOTE: Can't check NestedSet for literal int wen used with a float because any int is a valid float +with_descriptors.set_tuple = "a" +with_descriptors.set_tuple = 0 +with_descriptors.set_tuple = 0.0 +with_descriptors.set_tuple = None # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy +with_descriptors.set_tuple = "none" # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy +with_descriptors.set_tuple = object() # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy +with_descriptors.set_tuple = cast(_HasTagAndGet[Literal["a"]], _) +with_descriptors.set_tuple = cast(_HasTagAndGet[str], _) # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy +with_descriptors.set_tuple = cast(_HasTagAndGet[None], _) # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy +with_descriptors.set_tuple = cast(_HasTagAndGet[object], _) # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy + +with_descriptors.set_list = "a" +with_descriptors.set_list = 0 +with_descriptors.set_list = 0.0 +with_descriptors.set_list = None # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy +with_descriptors.set_list = "none" # can't check literals validity +with_descriptors.set_list = object() # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy +with_descriptors.set_list = cast(_HasTagAndGet[Literal["a"]], _) +with_descriptors.set_list = cast(_HasTagAndGet[str], _) # can't check literals validity +with_descriptors.set_list = cast(_HasTagAndGet[None], _) # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy +with_descriptors.set_list = cast(_HasTagAndGet[object], _) # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy + +with_descriptors.set_tuple_none = "a" +with_descriptors.set_tuple_none = 0 +with_descriptors.set_tuple_none = 0.0 +with_descriptors.set_tuple_none = None +with_descriptors.set_tuple_none = "none" # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy +with_descriptors.set_tuple_none = object() # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy +with_descriptors.set_tuple_none = cast(_HasTagAndGet[Literal["a"]], _) +with_descriptors.set_tuple_none = cast(_HasTagAndGet[str], _) # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy +with_descriptors.set_tuple_none = cast(_HasTagAndGet[None], _) +with_descriptors.set_tuple_none = cast( # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy + _HasTagAndGet[object], _ +) + + +with_descriptors.noneset_tuple = "a" +with_descriptors.noneset_tuple = 0 +with_descriptors.noneset_tuple = 0.0 +with_descriptors.noneset_tuple = None +with_descriptors.noneset_tuple = "none" +with_descriptors.noneset_tuple = object() # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy +with_descriptors.noneset_tuple = cast(_HasTagAndGet[Literal["a"]], _) +with_descriptors.noneset_tuple = cast(_HasTagAndGet[str], _) # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy +with_descriptors.noneset_tuple = cast(_HasTagAndGet[None], _) +with_descriptors.noneset_tuple = cast( # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy + _HasTagAndGet[object], _ +) + +with_descriptors.noneset_list = "a" +with_descriptors.noneset_list = 0 +with_descriptors.noneset_list = 0.0 +with_descriptors.noneset_list = None +with_descriptors.noneset_list = "none" +with_descriptors.noneset_list = object() # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy +with_descriptors.noneset_list = cast(_HasTagAndGet[Literal["a"]], _) +with_descriptors.noneset_list = cast(_HasTagAndGet[str], _) +with_descriptors.noneset_list = cast(_HasTagAndGet[None], _) +with_descriptors.noneset_list = cast( # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy + _HasTagAndGet[object], _ +) + + +with_descriptors.convertible_not_none = 0 +with_descriptors.convertible_not_none = "0" +with_descriptors.convertible_not_none = None # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy +with_descriptors.convertible_not_none = object() # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy +with_descriptors.convertible_not_none = cast(_HasTagAndGet[str], _) +with_descriptors.convertible_not_none = cast( # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy + _HasTagAndGet[None], _ +) +with_descriptors.convertible_not_none = cast( # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy + _HasTagAndGet[object], _ +) + +with_descriptors.convertible_none = 0 +with_descriptors.convertible_none = "0" +with_descriptors.convertible_none = None +with_descriptors.convertible_none = object() # FIXME: False negative(?) in pyright and mypy +with_descriptors.convertible_none = cast(_HasTagAndGet[str], _) +with_descriptors.convertible_none = cast(_HasTagAndGet[None], _) +with_descriptors.convertible_none = cast(_HasTagAndGet[object], _) # FIXME: False negative(?) in pyright and mypy + + +with_descriptors.text_str_not_none = 0 +with_descriptors.text_str_not_none = "0" +with_descriptors.text_str_not_none = None +with_descriptors.text_str_not_none = object() +with_descriptors.text_str_not_none = cast(_HasTagAndGet[str], _) +with_descriptors.text_str_not_none = cast(_HasTagAndGet[None], _) +with_descriptors.text_str_not_none = cast(_HasTagAndGet[object], _) + +with_descriptors.text_str_none = 0 +with_descriptors.text_str_none = "0" +with_descriptors.text_str_none = None +with_descriptors.text_str_none = object() +with_descriptors.text_str_none = cast(_HasTagAndGet[str], _) +with_descriptors.text_str_none = cast(_HasTagAndGet[None], _) +with_descriptors.text_str_none = cast(_HasTagAndGet[object], _) + +with_descriptors.text_int_not_none = 0 +with_descriptors.text_int_not_none = "0" +with_descriptors.text_int_not_none = None # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy +with_descriptors.text_int_not_none = object() # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy +# If expected type (_T) is not str, it's impossible to use an Element as the value +with_descriptors.text_int_not_none = cast( # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy + _HasTagAndGet[int], _ +) +with_descriptors.text_int_not_none = cast( # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy + _HasTagAndGet[None], _ +) +with_descriptors.text_int_not_none = cast( # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy + _HasTagAndGet[str], _ +) + +with_descriptors.text_int_none = 0 +with_descriptors.text_int_none = "0" +with_descriptors.text_int_none = None +with_descriptors.text_int_none = object() # FIXME: False negative(?) in pyright and mypy +# If expected type (_T) is not str, it's impossible to use an Element as the value +with_descriptors.text_int_none = cast(_HasTagAndGet[int], _) # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy +with_descriptors.text_int_none = cast(_HasTagAndGet[None], _) # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy +with_descriptors.text_int_none = cast(_HasTagAndGet[str], _) # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy + + +with_descriptors.minmax_float = 0 +with_descriptors.minmax_float = "0" +with_descriptors.minmax_float = 0.0 +with_descriptors.minmax_float = None # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy +with_descriptors.minmax_float = object() # type: ignore +with_descriptors.minmax_float = cast(_HasTagAndGet[float], _) +with_descriptors.minmax_float = cast(_HasTagAndGet[None], _) # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy +with_descriptors.minmax_float = cast(_HasTagAndGet[object], _) # type: ignore + +with_descriptors.minmax_float_none = 0 +with_descriptors.minmax_float_none = "0" +with_descriptors.minmax_float_none = 0.0 +with_descriptors.minmax_float_none = None +with_descriptors.minmax_float_none = object() # type: ignore +with_descriptors.minmax_float_none = cast(_HasTagAndGet[float], _) +with_descriptors.minmax_float_none = cast(_HasTagAndGet[None], _) +with_descriptors.minmax_float_none = cast(_HasTagAndGet[object], _) # type: ignore + +with_descriptors.minmax_int = 0 +with_descriptors.minmax_int = "0" +with_descriptors.minmax_int = 0.0 +with_descriptors.minmax_int = None # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy +with_descriptors.minmax_int = object() # type: ignore +with_descriptors.minmax_int = cast(_HasTagAndGet[int], _) +with_descriptors.minmax_int = cast(_HasTagAndGet[None], _) # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy +with_descriptors.minmax_int = cast(_HasTagAndGet[object], _) # type: ignore + +with_descriptors.minmax_int_none = 0 +with_descriptors.minmax_int_none = "0" +with_descriptors.minmax_int_none = 0.0 +with_descriptors.minmax_int_none = None +with_descriptors.minmax_int_none = object() # type: ignore +with_descriptors.minmax_int_none = cast(_HasTagAndGet[int], _) +with_descriptors.minmax_int_none = cast(_HasTagAndGet[None], _) +with_descriptors.minmax_int_none = cast(_HasTagAndGet[object], _) # type: ignore + + +with_descriptors.bool_not_none = False +with_descriptors.bool_not_none = "0" +with_descriptors.bool_not_none = 0 +with_descriptors.bool_not_none = None +with_descriptors.bool_not_none = 0.0 # type: ignore +with_descriptors.bool_not_none = object() # type: ignore +with_descriptors.bool_not_none = cast(_HasTagAndGet[bool], _) +with_descriptors.bool_not_none = cast(_HasTagAndGet[None], _) +with_descriptors.bool_not_none = cast(_HasTagAndGet[float], _) # type: ignore + +with_descriptors.bool_none = False +with_descriptors.bool_none = "0" +with_descriptors.bool_none = 0 +with_descriptors.bool_none = None +with_descriptors.bool_none = 0.0 # type: ignore +with_descriptors.bool_none = object() # type: ignore +with_descriptors.bool_none = cast(_HasTagAndGet[bool], _) +with_descriptors.bool_none = cast(_HasTagAndGet[None], _) +with_descriptors.bool_none = cast(_HasTagAndGet[float], _) # type: ignore + + +with_descriptors.emptytag_not_none = False +with_descriptors.emptytag_not_none = "0" +with_descriptors.emptytag_not_none = 0 +with_descriptors.emptytag_not_none = None +with_descriptors.emptytag_not_none = 0.0 # type: ignore +with_descriptors.emptytag_not_none = object() # type: ignore +with_descriptors.emptytag_not_none = cast(_HasTagAndGet[bool], _) +with_descriptors.emptytag_not_none = cast(_HasTagAndGet[None], _) +with_descriptors.emptytag_not_none = cast(_HasTagAndGet[float], _) # type: ignore + +with_descriptors.emptytag_none = False +with_descriptors.emptytag_none = "0" +with_descriptors.emptytag_none = 0 +with_descriptors.emptytag_none = None +with_descriptors.emptytag_none = 0.0 # type: ignore +with_descriptors.emptytag_none = object() # type: ignore +with_descriptors.emptytag_none = cast(_HasTagAndGet[bool], _) +with_descriptors.emptytag_none = cast(_HasTagAndGet[None], _) +with_descriptors.emptytag_none = cast(_HasTagAndGet[float], _) # type: ignore + + +with_descriptors.string_not_none = "" +with_descriptors.string_not_none = None +with_descriptors.string_not_none = 0 +with_descriptors.string_not_none = object() +with_descriptors.string_not_none = cast(_HasTagAndGet[str], _) +with_descriptors.string_not_none = cast(_HasTagAndGet[None], _) +with_descriptors.string_not_none = cast(_HasTagAndGet[int], _) +with_descriptors.string_not_none = cast(_HasTagAndGet[object], _) + +with_descriptors.string_none = "" +with_descriptors.string_none = None +with_descriptors.string_none = 0 +with_descriptors.string_none = object() +with_descriptors.string_none = cast(_HasTagAndGet[str], _) +with_descriptors.string_none = cast(_HasTagAndGet[None], _) +with_descriptors.string_none = cast(_HasTagAndGet[int], _) +with_descriptors.string_none = cast(_HasTagAndGet[object], _) + + +with_descriptors.float_not_none = 0 +with_descriptors.float_not_none = 0.0 +with_descriptors.float_not_none = "0" +with_descriptors.float_not_none = b"0" +with_descriptors.float_not_none = None # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy +with_descriptors.float_not_none = object() # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy +with_descriptors.float_not_none = cast(_HasTagAndGet[float], _) +with_descriptors.float_not_none = cast( # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy + _HasTagAndGet[None], _ +) +with_descriptors.float_not_none = cast( # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy + _HasTagAndGet[object], _ +) + +with_descriptors.float_none = 0 +with_descriptors.float_none = 0.0 +with_descriptors.float_none = "0" +with_descriptors.float_none = b"0" +with_descriptors.float_none = None +with_descriptors.float_none = object() # FIXME: False negative(?) in pyright and mypy +with_descriptors.float_none = cast(_HasTagAndGet[float], _) +with_descriptors.float_none = cast(_HasTagAndGet[None], _) +with_descriptors.float_none = cast(_HasTagAndGet[object], _) # FIXME: False negative(?) in pyright and mypy + + +with_descriptors.integer_not_none = 0 +with_descriptors.integer_not_none = 0.0 +with_descriptors.integer_not_none = "0" +with_descriptors.integer_not_none = b"0" +with_descriptors.integer_not_none = None # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy +with_descriptors.integer_not_none = object() # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy +with_descriptors.integer_not_none = cast(_HasTagAndGet[int], _) +with_descriptors.integer_not_none = cast( # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy + _HasTagAndGet[None], _ +) +with_descriptors.integer_not_none = cast( # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy + _HasTagAndGet[object], _ +) + +with_descriptors.integer_none = 0 +with_descriptors.integer_none = 0.0 +with_descriptors.integer_none = "0" +with_descriptors.integer_none = b"0" +with_descriptors.integer_none = None +with_descriptors.integer_none = object() # FIXME: False negative(?) in pyright and mypy +with_descriptors.integer_none = cast(_HasTagAndGet[int], _) +with_descriptors.integer_none = cast(_HasTagAndGet[None], _) +with_descriptors.integer_none = cast(_HasTagAndGet[object], _) # FIXME: False negative(?) in pyright and mypy diff --git a/stubs/openpyxl/openpyxl/cell/text.pyi b/stubs/openpyxl/openpyxl/cell/text.pyi index 909358848..fc4ffd1a2 100644 --- a/stubs/openpyxl/openpyxl/cell/text.pyi +++ b/stubs/openpyxl/openpyxl/cell/text.pyi @@ -3,6 +3,7 @@ from typing import ClassVar from typing_extensions import Literal, TypeAlias from openpyxl.descriptors.base import Alias, Integer, NoneSet, Typed, _ConvertibleToInt +from openpyxl.descriptors.nested import NestedString, NestedText from openpyxl.descriptors.serialisable import Serialisable from openpyxl.styles.fonts import Font @@ -27,13 +28,13 @@ class PhoneticText(Serialisable): tagname: str sb: Integer[Literal[False]] eb: Integer[Literal[False]] - t: Incomplete + t: NestedText[str, Literal[False]] text: Alias - def __init__(self, sb: _ConvertibleToInt, eb: _ConvertibleToInt, t: Incomplete | None = None) -> None: ... + def __init__(self, sb: _ConvertibleToInt, eb: _ConvertibleToInt, t: object = None) -> None: ... class InlineFont(Font): tagname: str - rFont: Incomplete + rFont: NestedString[Literal[True]] charset: Incomplete family: Incomplete b: Incomplete @@ -51,7 +52,7 @@ class InlineFont(Font): __elements__: ClassVar[tuple[str, ...]] def __init__( self, - rFont: Incomplete | None = None, + rFont: object = None, charset: Incomplete | None = None, family: Incomplete | None = None, b: Incomplete | None = None, @@ -72,14 +73,14 @@ class RichText(Serialisable): tagname: str rPr: Typed[InlineFont, Literal[True]] font: Alias - t: Incomplete + t: NestedText[str, Literal[True]] text: Alias __elements__: ClassVar[tuple[str, ...]] - def __init__(self, rPr: InlineFont | None = None, t: Incomplete | None = None) -> None: ... + def __init__(self, rPr: InlineFont | None = None, t: object = None) -> None: ... class Text(Serialisable): tagname: str - t: Incomplete + t: NestedText[str, Literal[True]] plain: Alias r: Incomplete formatted: Alias @@ -88,6 +89,6 @@ class Text(Serialisable): phoneticPr: Typed[_PhoneticProperties, Literal[True]] PhoneticProperties: Alias __elements__: ClassVar[tuple[str, ...]] - def __init__(self, t: Incomplete | None = None, r=(), rPh=(), phoneticPr: _PhoneticProperties | None = None) -> None: ... + def __init__(self, t: object = None, r=(), rPh=(), phoneticPr: _PhoneticProperties | None = None) -> None: ... @property def content(self): ... diff --git a/stubs/openpyxl/openpyxl/chart/_3d.pyi b/stubs/openpyxl/openpyxl/chart/_3d.pyi index d11b2af0a..df7ae2bf0 100644 --- a/stubs/openpyxl/openpyxl/chart/_3d.pyi +++ b/stubs/openpyxl/openpyxl/chart/_3d.pyi @@ -1,41 +1,42 @@ -from _typeshed import Incomplete, Unused +from _typeshed import Unused from typing import ClassVar from typing_extensions import Literal from openpyxl.chart.picture import PictureOptions from openpyxl.chart.shapes import GraphicalProperties -from openpyxl.descriptors.base import Alias, Typed +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.serialisable import Serialisable class View3D(Serialisable): tagname: str - rotX: Incomplete + rotX: NestedMinMax[float, Literal[True]] x_rotation: Alias - hPercent: Incomplete + hPercent: NestedMinMax[float, Literal[True]] height_percent: Alias - rotY: Incomplete + rotY: NestedInteger[Literal[True]] y_rotation: Alias - depthPercent: Incomplete - rAngAx: Incomplete + depthPercent: NestedInteger[Literal[True]] + rAngAx: NestedBool[Literal[True]] right_angle_axes: Alias - perspective: Incomplete + perspective: NestedInteger[Literal[True]] extLst: Typed[ExtensionList, Literal[True]] __elements__: ClassVar[tuple[str, ...]] def __init__( self, - rotX: int = 15, - hPercent: Incomplete | None = None, - rotY: int = 20, - depthPercent: Incomplete | None = None, - rAngAx: bool = True, - perspective: Incomplete | None = None, + rotX: _HasTagAndGet[_ConvertibleToFloat | None] | _ConvertibleToFloat | None = 15, + hPercent: _HasTagAndGet[_ConvertibleToFloat | None] | _ConvertibleToFloat | None = None, + rotY: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = 20, + depthPercent: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + rAngAx: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = True, + perspective: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, extLst: Unused = None, ) -> None: ... class Surface(Serialisable): tagname: str - thickness: Incomplete + thickness: NestedInteger[Literal[True]] spPr: Typed[GraphicalProperties, Literal[True]] graphicalProperties: Alias pictureOptions: Typed[PictureOptions, Literal[True]] @@ -43,7 +44,7 @@ class Surface(Serialisable): __elements__: ClassVar[tuple[str, ...]] def __init__( self, - thickness: Incomplete | None = None, + thickness: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, spPr: GraphicalProperties | None = None, pictureOptions: PictureOptions | None = None, extLst: Unused = None, diff --git a/stubs/openpyxl/openpyxl/chart/area_chart.pyi b/stubs/openpyxl/openpyxl/chart/area_chart.pyi index c9b82946d..d583364ff 100644 --- a/stubs/openpyxl/openpyxl/chart/area_chart.pyi +++ b/stubs/openpyxl/openpyxl/chart/area_chart.pyi @@ -1,18 +1,21 @@ from _typeshed import Incomplete, Unused from abc import abstractmethod from typing import ClassVar -from typing_extensions import Literal +from typing_extensions import Literal, TypeAlias from openpyxl.chart.axis import ChartLines, NumericAxis, SeriesAxis, TextAxis from openpyxl.chart.label import DataLabelList -from openpyxl.descriptors.base import Alias, Typed +from openpyxl.descriptors.base import Alias, Typed, _ConvertibleToBool from openpyxl.descriptors.excel import ExtensionList +from openpyxl.descriptors.nested import NestedBool, NestedSet, _HasTagAndGet from ._chart import ChartBase +_AreaChartBaseGrouping: TypeAlias = Literal["percentStacked", "standard", "stacked"] + class _AreaChartBase(ChartBase): - grouping: Incomplete - varyColors: Incomplete + grouping: NestedSet[_AreaChartBaseGrouping] + varyColors: NestedBool[Literal[True]] ser: Incomplete dLbls: Typed[DataLabelList, Literal[True]] dataLabels: Alias @@ -20,8 +23,8 @@ class _AreaChartBase(ChartBase): __elements__: ClassVar[tuple[str, ...]] def __init__( self, - grouping: str = "standard", - varyColors: Incomplete | None = None, + grouping: _HasTagAndGet[_AreaChartBaseGrouping] | _AreaChartBaseGrouping = "standard", + varyColors: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, ser=(), dLbls: DataLabelList | None = None, dropLines: ChartLines | None = None, diff --git a/stubs/openpyxl/openpyxl/chart/axis.pyi b/stubs/openpyxl/openpyxl/chart/axis.pyi index 258437879..70904da10 100644 --- a/stubs/openpyxl/openpyxl/chart/axis.pyi +++ b/stubs/openpyxl/openpyxl/chart/axis.pyi @@ -1,15 +1,45 @@ from _typeshed import Incomplete, Unused from abc import abstractmethod -from typing import ClassVar -from typing_extensions import Literal +from typing import ClassVar, overload +from typing_extensions import Literal, TypeAlias from openpyxl.chart.layout import Layout from openpyxl.chart.shapes import GraphicalProperties from openpyxl.chart.text import RichText, Text -from openpyxl.descriptors.base import Alias, Typed +from openpyxl.descriptors.base import Alias, Typed, _ConvertibleToBool, _ConvertibleToFloat, _ConvertibleToInt from openpyxl.descriptors.excel import ExtensionList +from openpyxl.descriptors.nested import ( + NestedBool, + NestedFloat, + NestedInteger, + NestedMinMax, + NestedNoneSet, + NestedSet, + _HasTagAndGet, + _NestedNoneSetParam, +) from openpyxl.descriptors.serialisable import Serialisable +_ScalingOrientation: TypeAlias = Literal["maxMin", "minMax"] +_BaseAxisAxPos: TypeAlias = Literal["b", "l", "r", "t"] +_BaseAxisTickMark: TypeAlias = Literal["cross", "in", "out"] +_BaseAxisTickLblPos: TypeAlias = Literal["high", "low", "nextTo"] +_BaseAxisCrosses: TypeAlias = Literal["autoZero", "max", "min"] +_DisplayUnitsLabelListBuiltInUnit: TypeAlias = Literal[ + "hundreds", + "thousands", + "tenThousands", + "hundredThousands", + "millions", + "tenMillions", + "hundredMillions", + "billions", + "trillions", +] +_NumericAxisCrossBetween: TypeAlias = Literal["between", "midCat"] +_TextAxisLblAlgn: TypeAlias = Literal["ctr", "l", "r"] +_DateAxisTimeUnit: TypeAlias = Literal["days", "months", "years"] + class ChartLines(Serialisable): tagname: str spPr: Typed[GraphicalProperties, Literal[True]] @@ -18,48 +48,69 @@ class ChartLines(Serialisable): class Scaling(Serialisable): tagname: str - logBase: Incomplete - orientation: Incomplete - max: Incomplete - min: Incomplete + logBase: NestedFloat[Literal[True]] + orientation: NestedSet[_ScalingOrientation] + max: NestedFloat[Literal[True]] + min: NestedFloat[Literal[True]] extLst: Typed[ExtensionList, Literal[True]] __elements__: ClassVar[tuple[str, ...]] def __init__( self, - logBase: Incomplete | None = None, - orientation: str = "minMax", - max: Incomplete | None = None, - min: Incomplete | None = None, + logBase: _HasTagAndGet[_ConvertibleToFloat | None] | _ConvertibleToFloat | None = None, + orientation: _HasTagAndGet[_ScalingOrientation] | _ScalingOrientation = "minMax", + max: _HasTagAndGet[_ConvertibleToFloat | None] | _ConvertibleToFloat | None = None, + min: _HasTagAndGet[_ConvertibleToFloat | None] | _ConvertibleToFloat | None = None, extLst: Unused = None, ) -> None: ... class _BaseAxis(Serialisable): - axId: Incomplete + axId: NestedInteger[Literal[False]] scaling: Typed[Scaling, Literal[False]] - delete: Incomplete - axPos: Incomplete + delete: NestedBool[Literal[True]] + axPos: NestedSet[_BaseAxisAxPos] majorGridlines: Typed[ChartLines, Literal[True]] minorGridlines: Typed[ChartLines, Literal[True]] title: Incomplete numFmt: Incomplete number_format: Alias - majorTickMark: Incomplete - minorTickMark: Incomplete - tickLblPos: Incomplete + majorTickMark: NestedNoneSet[_BaseAxisTickMark] + minorTickMark: NestedNoneSet[_BaseAxisTickMark] + tickLblPos: NestedNoneSet[_BaseAxisTickLblPos] spPr: Typed[GraphicalProperties, Literal[True]] graphicalProperties: Alias txPr: Typed[RichText, Literal[True]] textProperties: Alias - crossAx: Incomplete - crosses: Incomplete - crossesAt: Incomplete + crossAx: NestedInteger[Literal[False]] + crosses: NestedNoneSet[_BaseAxisCrosses] + crossesAt: NestedFloat[Literal[True]] __elements__: ClassVar[tuple[str, ...]] + @overload def __init__( self, - axId: Incomplete | None = None, + axId: _HasTagAndGet[_ConvertibleToInt] | _ConvertibleToInt, + scaling: Scaling | None, + delete: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None, + axPos: _HasTagAndGet[_BaseAxisAxPos] | _BaseAxisAxPos, + majorGridlines: ChartLines | None, + minorGridlines: ChartLines | None, + title: Incomplete | None, + numFmt: Incomplete | None, + majorTickMark: _NestedNoneSetParam[_BaseAxisTickMark], + minorTickMark: _NestedNoneSetParam[_BaseAxisTickMark], + tickLblPos: _NestedNoneSetParam[_BaseAxisTickLblPos], + spPr: GraphicalProperties | None, + txPr: RichText | None, + crossAx: _HasTagAndGet[_ConvertibleToInt] | _ConvertibleToInt, + crosses: _NestedNoneSetParam[_BaseAxisCrosses] = None, + crossesAt: _HasTagAndGet[_ConvertibleToFloat | None] | _ConvertibleToFloat | None = None, + ) -> None: ... + @overload + def __init__( + self, + axId: _HasTagAndGet[_ConvertibleToInt] | _ConvertibleToInt, scaling: Scaling | None = None, - delete: Incomplete | None = None, - axPos: str = "l", + delete: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, + axPos: _HasTagAndGet[_BaseAxisAxPos] | _BaseAxisAxPos = "l", majorGridlines: ChartLines | None = None, minorGridlines: ChartLines | None = None, title: Incomplete | None = None, @@ -69,9 +120,10 @@ class _BaseAxis(Serialisable): tickLblPos: Incomplete | None = None, spPr: GraphicalProperties | None = None, txPr: RichText | None = None, - crossAx: Incomplete | None = None, + *, + crossAx: _HasTagAndGet[_ConvertibleToInt] | _ConvertibleToInt, crosses: Incomplete | None = None, - crossesAt: Incomplete | None = None, + crossesAt: _HasTagAndGet[_ConvertibleToFloat | None] | _ConvertibleToFloat | None = None, ) -> None: ... @property @abstractmethod @@ -97,15 +149,18 @@ class DisplayUnitsLabel(Serialisable): class DisplayUnitsLabelList(Serialisable): tagname: str - custUnit: Incomplete - builtInUnit: Incomplete + custUnit: NestedFloat[Literal[True]] + builtInUnit: NestedNoneSet[_DisplayUnitsLabelListBuiltInUnit] dispUnitsLbl: Typed[DisplayUnitsLabel, Literal[True]] extLst: Typed[ExtensionList, Literal[True]] __elements__: ClassVar[tuple[str, ...]] def __init__( self, - custUnit: Incomplete | None = None, - builtInUnit: Incomplete | None = None, + custUnit: _HasTagAndGet[_ConvertibleToFloat | None] | _ConvertibleToFloat | None = None, + builtInUnit: _HasTagAndGet[_DisplayUnitsLabelListBuiltInUnit] + | _DisplayUnitsLabelListBuiltInUnit + | Literal["none"] + | None = None, dispUnitsLbl: DisplayUnitsLabel | None = None, extLst: Unused = None, ) -> None: ... @@ -128,17 +183,17 @@ class NumericAxis(_BaseAxis): crossAx: Incomplete crosses: Incomplete crossesAt: Incomplete - crossBetween: Incomplete - majorUnit: Incomplete - minorUnit: Incomplete + crossBetween: NestedNoneSet[_NumericAxisCrossBetween] + majorUnit: NestedFloat[Literal[True]] + minorUnit: NestedFloat[Literal[True]] dispUnits: Typed[DisplayUnitsLabelList, Literal[True]] extLst: Typed[ExtensionList, Literal[True]] __elements__: ClassVar[tuple[str, ...]] def __init__( self, - crossBetween: Incomplete | None = None, - majorUnit: Incomplete | None = None, - minorUnit: Incomplete | None = None, + crossBetween: _NestedNoneSetParam[_NumericAxisCrossBetween] = None, + majorUnit: _HasTagAndGet[_ConvertibleToFloat | None] | _ConvertibleToFloat | None = None, + minorUnit: _HasTagAndGet[_ConvertibleToFloat | None] | _ConvertibleToFloat | None = None, dispUnits: DisplayUnitsLabelList | None = None, extLst: Unused = None, **kw, @@ -164,22 +219,22 @@ class TextAxis(_BaseAxis): crossAx: Incomplete crosses: Incomplete crossesAt: Incomplete - auto: Incomplete - lblAlgn: Incomplete - lblOffset: Incomplete - tickLblSkip: Incomplete - tickMarkSkip: Incomplete - noMultiLvlLbl: Incomplete + auto: NestedBool[Literal[True]] + lblAlgn: NestedNoneSet[_TextAxisLblAlgn] + lblOffset: NestedMinMax[float, Literal[False]] + tickLblSkip: NestedInteger[Literal[True]] + tickMarkSkip: NestedInteger[Literal[True]] + noMultiLvlLbl: NestedBool[Literal[True]] extLst: Typed[ExtensionList, Literal[True]] __elements__: ClassVar[tuple[str, ...]] def __init__( self, - auto: Incomplete | None = None, - lblAlgn: Incomplete | None = None, - lblOffset: int = 100, - tickLblSkip: Incomplete | None = None, - tickMarkSkip: Incomplete | None = None, - noMultiLvlLbl: Incomplete | None = None, + auto: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, + lblAlgn: _NestedNoneSetParam[_TextAxisLblAlgn] = None, + lblOffset: _HasTagAndGet[_ConvertibleToFloat] | _ConvertibleToFloat = 100, + tickLblSkip: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + tickMarkSkip: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + noMultiLvlLbl: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, extLst: Unused = None, **kw, ) -> None: ... @@ -202,24 +257,24 @@ class DateAxis(TextAxis): crossAx: Incomplete crosses: Incomplete crossesAt: Incomplete - auto: Incomplete - lblOffset: Incomplete - baseTimeUnit: Incomplete - majorUnit: Incomplete - majorTimeUnit: Incomplete - minorUnit: Incomplete - minorTimeUnit: Incomplete + auto: NestedBool[Literal[True]] + lblOffset: NestedInteger[Literal[True]] # type: ignore[assignment] + baseTimeUnit: NestedNoneSet[_DateAxisTimeUnit] + majorUnit: NestedFloat[Literal[True]] + majorTimeUnit: NestedNoneSet[_DateAxisTimeUnit] + minorUnit: NestedFloat[Literal[True]] + minorTimeUnit: NestedNoneSet[_DateAxisTimeUnit] extLst: Typed[ExtensionList, Literal[True]] __elements__: ClassVar[tuple[str, ...]] def __init__( self, - auto: Incomplete | None = None, - lblOffset: Incomplete | None = None, - baseTimeUnit: Incomplete | None = None, - majorUnit: Incomplete | None = None, - majorTimeUnit: Incomplete | None = None, - minorUnit: Incomplete | None = None, - minorTimeUnit: Incomplete | None = None, + auto: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, + lblOffset: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + baseTimeUnit: _NestedNoneSetParam[_DateAxisTimeUnit] = None, + majorUnit: _HasTagAndGet[_ConvertibleToFloat | None] | _ConvertibleToFloat | None = None, + majorTimeUnit: _NestedNoneSetParam[_DateAxisTimeUnit] = None, + minorUnit: _HasTagAndGet[_ConvertibleToFloat | None] | _ConvertibleToFloat | None = None, + minorTimeUnit: _NestedNoneSetParam[_DateAxisTimeUnit] = None, extLst: Unused = None, **kw, ) -> None: ... @@ -242,10 +297,14 @@ class SeriesAxis(_BaseAxis): crossAx: Incomplete crosses: Incomplete crossesAt: Incomplete - tickLblSkip: Incomplete - tickMarkSkip: Incomplete + tickLblSkip: NestedInteger[Literal[True]] + tickMarkSkip: NestedInteger[Literal[True]] extLst: Typed[ExtensionList, Literal[True]] __elements__: ClassVar[tuple[str, ...]] def __init__( - self, tickLblSkip: Incomplete | None = None, tickMarkSkip: Incomplete | None = None, extLst: Unused = None, **kw + self, + tickLblSkip: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + tickMarkSkip: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + extLst: Unused = None, + **kw, ) -> None: ... diff --git a/stubs/openpyxl/openpyxl/chart/bar_chart.pyi b/stubs/openpyxl/openpyxl/chart/bar_chart.pyi index f06b54c64..16f52f377 100644 --- a/stubs/openpyxl/openpyxl/chart/bar_chart.pyi +++ b/stubs/openpyxl/openpyxl/chart/bar_chart.pyi @@ -1,30 +1,35 @@ from _typeshed import Incomplete, Unused from abc import abstractmethod from typing import ClassVar -from typing_extensions import Literal +from typing_extensions import Literal, TypeAlias from openpyxl.chart.axis import ChartLines, NumericAxis, SeriesAxis, TextAxis from openpyxl.chart.label import DataLabelList -from openpyxl.descriptors.base import Alias, Typed +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 ._3d import _3DBase from ._chart import ChartBase +_BarChartBaseBarDir: TypeAlias = Literal["bar", "col"] +_BarChartBaseGrouping: TypeAlias = Literal["percentStacked", "clustered", "standard", "stacked"] +_BarChart3DShape: TypeAlias = Literal["cone", "coneToMax", "box", "cylinder", "pyramid", "pyramidToMax"] + class _BarChartBase(ChartBase): - barDir: Incomplete + barDir: NestedSet[_BarChartBaseBarDir] type: Alias - grouping: Incomplete - varyColors: Incomplete + grouping: NestedSet[_BarChartBaseGrouping] + varyColors: NestedBool[Literal[True]] ser: Incomplete dLbls: Typed[DataLabelList, Literal[True]] dataLabels: Alias __elements__: ClassVar[tuple[str, ...]] def __init__( self, - barDir: str = "col", - grouping: str = "clustered", - varyColors: Incomplete | None = None, + barDir: _HasTagAndGet[_BarChartBaseBarDir] | _BarChartBaseBarDir = "col", + grouping: _HasTagAndGet[_BarChartBaseGrouping] | _BarChartBaseGrouping = "clustered", + varyColors: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, ser=(), dLbls: DataLabelList | None = None, **kw, @@ -70,7 +75,7 @@ class BarChart3D(_BarChartBase, _3DBase): backWall: Incomplete gapWidth: Incomplete gapDepth: Incomplete - shape: Incomplete + shape: NestedNoneSet[_BarChart3DShape] serLines: Typed[ChartLines, Literal[True]] extLst: Typed[ExtensionList, Literal[True]] x_axis: Typed[TextAxis, Literal[False]] @@ -81,7 +86,7 @@ class BarChart3D(_BarChartBase, _3DBase): self, gapWidth: int = 150, gapDepth: int = 150, - shape: Incomplete | None = None, + shape: _NestedNoneSetParam[_BarChart3DShape] = None, serLines: ChartLines | None = None, extLst: Unused = None, **kw, diff --git a/stubs/openpyxl/openpyxl/chart/bubble_chart.pyi b/stubs/openpyxl/openpyxl/chart/bubble_chart.pyi index a1ba6637d..b3c1050d7 100644 --- a/stubs/openpyxl/openpyxl/chart/bubble_chart.pyi +++ b/stubs/openpyxl/openpyxl/chart/bubble_chart.pyi @@ -1,37 +1,40 @@ from _typeshed import Incomplete, Unused from typing import ClassVar -from typing_extensions import Literal +from typing_extensions import Literal, TypeAlias from openpyxl.chart.axis import NumericAxis from openpyxl.chart.label import DataLabelList -from openpyxl.descriptors.base import Alias, Typed +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 ._chart import ChartBase +_BubbleChartSizeRepresents: TypeAlias = Literal["area", "w"] + class BubbleChart(ChartBase): tagname: str - varyColors: Incomplete + varyColors: NestedBool[Literal[True]] ser: Incomplete dLbls: Typed[DataLabelList, Literal[True]] dataLabels: Alias - bubble3D: Incomplete - bubbleScale: Incomplete - showNegBubbles: Incomplete - sizeRepresents: Incomplete + bubble3D: NestedBool[Literal[True]] + bubbleScale: NestedMinMax[float, Literal[True]] + showNegBubbles: NestedBool[Literal[True]] + sizeRepresents: NestedNoneSet[_BubbleChartSizeRepresents] extLst: Typed[ExtensionList, Literal[True]] x_axis: Typed[NumericAxis, Literal[False]] y_axis: Typed[NumericAxis, Literal[False]] __elements__: ClassVar[tuple[str, ...]] def __init__( self, - varyColors: Incomplete | None = None, + varyColors: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, ser=(), dLbls: DataLabelList | None = None, - bubble3D: Incomplete | None = None, - bubbleScale: Incomplete | None = None, - showNegBubbles: Incomplete | None = None, - sizeRepresents: Incomplete | None = None, + bubble3D: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, + bubbleScale: _HasTagAndGet[_ConvertibleToFloat | None] | _ConvertibleToFloat | None = None, + showNegBubbles: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, + sizeRepresents: _NestedNoneSetParam[_BubbleChartSizeRepresents] = None, extLst: Unused = None, **kw, ) -> None: ... diff --git a/stubs/openpyxl/openpyxl/chart/chartspace.pyi b/stubs/openpyxl/openpyxl/chart/chartspace.pyi index ad1da05ff..b404b9ca0 100644 --- a/stubs/openpyxl/openpyxl/chart/chartspace.pyi +++ b/stubs/openpyxl/openpyxl/chart/chartspace.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete, Unused from typing import ClassVar, overload -from typing_extensions import Literal +from typing_extensions import Literal, TypeAlias from openpyxl.chart.legend import Legend from openpyxl.chart.pivot import PivotSource @@ -9,15 +9,18 @@ from openpyxl.chart.print_settings import PrintSettings from openpyxl.chart.shapes import GraphicalProperties from openpyxl.chart.text import RichText from openpyxl.chart.title import Title -from openpyxl.descriptors.base import Alias, String, Typed +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.serialisable import Serialisable from openpyxl.drawing.colors import ColorMapping +_ChartContainerDispBlanksAs: TypeAlias = Literal["span", "gap", "zero"] + class ChartContainer(Serialisable): tagname: str title: Typed[Title, Literal[True]] - autoTitleDeleted: Incomplete + autoTitleDeleted: NestedBool[Literal[True]] pivotFmts: Incomplete view3D: Incomplete floor: Incomplete @@ -25,15 +28,15 @@ class ChartContainer(Serialisable): backWall: Incomplete plotArea: Typed[PlotArea, Literal[False]] legend: Typed[Legend, Literal[True]] - plotVisOnly: Incomplete - dispBlanksAs: Incomplete - showDLblsOverMax: Incomplete + plotVisOnly: NestedBool[Literal[False]] + dispBlanksAs: NestedNoneSet[_ChartContainerDispBlanksAs] + showDLblsOverMax: NestedBool[Literal[True]] extLst: Typed[ExtensionList, Literal[True]] __elements__: ClassVar[tuple[str, ...]] def __init__( self, title: Title | None = None, - autoTitleDeleted: Incomplete | None = None, + autoTitleDeleted: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, pivotFmts=(), view3D: Incomplete | None = None, floor: Incomplete | None = None, @@ -41,44 +44,46 @@ class ChartContainer(Serialisable): backWall: Incomplete | None = None, plotArea: PlotArea | None = None, legend: Legend | None = None, - plotVisOnly: bool = True, - dispBlanksAs: str = "gap", - showDLblsOverMax: Incomplete | None = None, + plotVisOnly: _HasTagAndGet[_ConvertibleToBool] | _ConvertibleToBool = True, + dispBlanksAs: _NestedNoneSetParam[_ChartContainerDispBlanksAs] = "gap", + showDLblsOverMax: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, extLst: Unused = None, ) -> None: ... class Protection(Serialisable): tagname: str - chartObject: Incomplete - data: Incomplete - formatting: Incomplete - selection: Incomplete - userInterface: Incomplete + chartObject: NestedBool[Literal[True]] + data: NestedBool[Literal[True]] + formatting: NestedBool[Literal[True]] + selection: NestedBool[Literal[True]] + userInterface: NestedBool[Literal[True]] __elements__: ClassVar[tuple[str, ...]] def __init__( self, - chartObject: Incomplete | None = None, - data: Incomplete | None = None, - formatting: Incomplete | None = None, - selection: Incomplete | None = None, - userInterface: Incomplete | None = None, + chartObject: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, + data: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, + formatting: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, + selection: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, + userInterface: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, ) -> None: ... class ExternalData(Serialisable): tagname: str - autoUpdate: Incomplete + autoUpdate: NestedBool[Literal[True]] id: String[Literal[False]] @overload - def __init__(self, autoUpdate: Incomplete | None = None, *, id: str) -> None: ... + def __init__( + self, autoUpdate: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, *, id: str + ) -> None: ... @overload def __init__(self, autoUpdate: Incomplete | None, id: str) -> None: ... class ChartSpace(Serialisable): tagname: str - date1904: Incomplete - lang: Incomplete - roundedCorners: Incomplete - style: Incomplete + date1904: NestedBool[Literal[True]] + lang: NestedString[Literal[True]] + roundedCorners: NestedBool[Literal[True]] + style: NestedMinMax[float, Literal[True]] clrMapOvr: Typed[ColorMapping, Literal[True]] pivotSource: Typed[PivotSource, Literal[True]] protection: Typed[Protection, Literal[True]] @@ -95,10 +100,10 @@ class ChartSpace(Serialisable): @overload def __init__( self, - date1904: Incomplete | None = None, - lang: Incomplete | None = None, - roundedCorners: Incomplete | None = None, - style: Incomplete | None = None, + date1904: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, + lang: object = None, + roundedCorners: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, + style: _HasTagAndGet[_ConvertibleToFloat | None] | _ConvertibleToFloat | None = None, clrMapOvr: ColorMapping | None = None, pivotSource: PivotSource | None = None, protection: Protection | None = None, @@ -114,10 +119,10 @@ class ChartSpace(Serialisable): @overload def __init__( self, - date1904: Incomplete | None, - lang: Incomplete | None, - roundedCorners: Incomplete | None, - style: Incomplete | None, + date1904: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None, + lang: object, + roundedCorners: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None, + style: _HasTagAndGet[_ConvertibleToFloat | None] | _ConvertibleToFloat | None, clrMapOvr: ColorMapping | None, pivotSource: PivotSource | None, protection: Protection | None, diff --git a/stubs/openpyxl/openpyxl/chart/data_source.pyi b/stubs/openpyxl/openpyxl/chart/data_source.pyi index 613f97de0..ad752c1d0 100644 --- a/stubs/openpyxl/openpyxl/chart/data_source.pyi +++ b/stubs/openpyxl/openpyxl/chart/data_source.pyi @@ -5,7 +5,7 @@ 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 NestedText +from openpyxl.descriptors.nested import NestedInteger, NestedText, _HasTagAndGet from openpyxl.descriptors.serialisable import Serialisable class NumFmt(Serialisable): @@ -13,56 +13,62 @@ class NumFmt(Serialisable): sourceLinked: Bool[Literal[False]] def __init__(self, formatCode: str, sourceLinked: _ConvertibleToBool = False) -> None: ... -class NumberValueDescriptor(NestedText): +class NumberValueDescriptor(NestedText[Incomplete, Incomplete]): allow_none: bool expected_type: type[Incomplete] def __set__(self, instance: Serialisable | Strict, value) -> None: ... # type: ignore[override] class NumVal(Serialisable): idx: Integer[Literal[False]] - formatCode: Incomplete + formatCode: NestedText[str, Literal[True]] v: Incomplete - def __init__(self, idx: _ConvertibleToInt, formatCode: Incomplete | None = None, v: Incomplete | None = None) -> None: ... + def __init__(self, idx: _ConvertibleToInt, formatCode: object = None, v: Incomplete | None = None) -> None: ... class NumData(Serialisable): - formatCode: Incomplete - ptCount: Incomplete + formatCode: NestedText[str, Literal[True]] + ptCount: NestedInteger[Literal[True]] pt: Incomplete extLst: Typed[ExtensionList, Literal[True]] __elements__: ClassVar[tuple[str, ...]] def __init__( - self, formatCode: Incomplete | None = None, ptCount: Incomplete | None = None, pt=(), extLst: Unused = None + self, + formatCode: object = None, + ptCount: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + pt=(), + extLst: Unused = None, ) -> None: ... class NumRef(Serialisable): - f: Incomplete + f: NestedText[str, Literal[False]] ref: Alias numCache: Typed[NumData, Literal[True]] extLst: Typed[ExtensionList, Literal[True]] __elements__: ClassVar[tuple[str, ...]] - def __init__(self, f: Incomplete | None = None, numCache: NumData | None = None, extLst: Unused = None) -> None: ... + def __init__(self, f: object = None, numCache: NumData | None = None, extLst: Unused = None) -> None: ... class StrVal(Serialisable): tagname: str idx: Integer[Literal[False]] - v: Incomplete - def __init__(self, idx: _ConvertibleToInt = 0, v: Incomplete | None = None) -> None: ... + v: NestedText[str, Literal[False]] + def __init__(self, idx: _ConvertibleToInt = 0, v: object = None) -> None: ... class StrData(Serialisable): tagname: str - ptCount: Incomplete + ptCount: NestedInteger[Literal[True]] pt: Incomplete extLst: Typed[ExtensionList, Literal[True]] __elements__: ClassVar[tuple[str, ...]] - def __init__(self, ptCount: Incomplete | None = None, pt=(), extLst: Unused = None) -> None: ... + def __init__( + self, ptCount: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, pt=(), extLst: Unused = None + ) -> None: ... class StrRef(Serialisable): tagname: str - f: Incomplete + f: NestedText[str, Literal[True]] strCache: Typed[StrData, Literal[True]] extLst: Typed[ExtensionList, Literal[True]] __elements__: ClassVar[tuple[str, ...]] - def __init__(self, f: Incomplete | None = None, strCache: StrData | None = None, extLst: Unused = None) -> None: ... + def __init__(self, f: object = None, strCache: StrData | None = None, extLst: Unused = None) -> None: ... class NumDataSource(Serialisable): numRef: Typed[NumRef, Literal[True]] @@ -85,13 +91,11 @@ class MultiLevelStrData(Serialisable): class MultiLevelStrRef(Serialisable): tagname: str - f: Incomplete + f: NestedText[str, Literal[False]] multiLvlStrCache: Typed[MultiLevelStrData, Literal[True]] extLst: Typed[ExtensionList, Literal[True]] __elements__: ClassVar[tuple[str, ...]] - def __init__( - self, f: Incomplete | None = None, multiLvlStrCache: MultiLevelStrData | None = None, extLst: Unused = None - ) -> None: ... + def __init__(self, f: object = None, multiLvlStrCache: MultiLevelStrData | None = None, extLst: Unused = None) -> None: ... class AxDataSource(Serialisable): tagname: str diff --git a/stubs/openpyxl/openpyxl/chart/descriptors.pyi b/stubs/openpyxl/openpyxl/chart/descriptors.pyi index 8cd163b1d..eb1d72593 100644 --- a/stubs/openpyxl/openpyxl/chart/descriptors.pyi +++ b/stubs/openpyxl/openpyxl/chart/descriptors.pyi @@ -1,4 +1,3 @@ -from _typeshed import Incomplete from typing_extensions import Literal from openpyxl.chart.data_source import NumFmt @@ -6,17 +5,17 @@ from openpyxl.descriptors import Strict, Typed from openpyxl.descriptors.nested import NestedMinMax from openpyxl.descriptors.serialisable import Serialisable -class NestedGapAmount(NestedMinMax): +class NestedGapAmount(NestedMinMax[float, bool]): allow_none: bool min: float max: float -class NestedOverlap(NestedMinMax): +class NestedOverlap(NestedMinMax[float, bool]): allow_none: bool min: float max: float -class NumberFormatDescriptor(Typed[NumFmt, Incomplete]): +class NumberFormatDescriptor(Typed[NumFmt, Literal[True]]): expected_type: type[NumFmt] allow_none: Literal[True] def __set__(self, instance: Serialisable | Strict, value) -> None: ... diff --git a/stubs/openpyxl/openpyxl/chart/error_bar.pyi b/stubs/openpyxl/openpyxl/chart/error_bar.pyi index 922c7ce25..b1b808f12 100644 --- a/stubs/openpyxl/openpyxl/chart/error_bar.pyi +++ b/stubs/openpyxl/openpyxl/chart/error_bar.pyi @@ -1,38 +1,43 @@ -from _typeshed import Incomplete, Unused +from _typeshed import Unused from typing import ClassVar -from typing_extensions import Literal +from typing_extensions import Literal, TypeAlias from openpyxl.chart.data_source import NumDataSource from openpyxl.chart.shapes import GraphicalProperties -from openpyxl.descriptors.base import Alias, Typed +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.serialisable import Serialisable +_ErrorBarsErrBarType: TypeAlias = Literal["both", "minus", "plus"] +_ErrorBarsErrValType: TypeAlias = Literal["cust", "fixedVal", "percentage", "stdDev", "stdErr"] +_ErrorBarsErrDir: TypeAlias = Literal["x", "y"] + class ErrorBars(Serialisable): tagname: str - errDir: Incomplete + errDir: NestedNoneSet[_ErrorBarsErrDir] direction: Alias - errBarType: Incomplete + errBarType: NestedSet[_ErrorBarsErrBarType] style: Alias - errValType: Incomplete + errValType: NestedSet[_ErrorBarsErrValType] size: Alias - noEndCap: Incomplete + noEndCap: NestedBool[Literal[True]] plus: Typed[NumDataSource, Literal[True]] minus: Typed[NumDataSource, Literal[True]] - val: Incomplete + val: NestedFloat[Literal[True]] spPr: Typed[GraphicalProperties, Literal[True]] graphicalProperties: Alias extLst: Typed[ExtensionList, Literal[True]] __elements__: ClassVar[tuple[str, ...]] def __init__( self, - errDir: Incomplete | None = None, - errBarType: str = "both", - errValType: str = "fixedVal", - noEndCap: Incomplete | None = None, + errDir: _NestedNoneSetParam[_ErrorBarsErrDir] = None, + errBarType: _HasTagAndGet[_ErrorBarsErrBarType] | _ErrorBarsErrBarType = "both", + errValType: _HasTagAndGet[_ErrorBarsErrValType] | _ErrorBarsErrValType = "fixedVal", + noEndCap: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, plus: NumDataSource | None = None, minus: NumDataSource | None = None, - val: Incomplete | None = None, + val: _HasTagAndGet[_ConvertibleToFloat | None] | _ConvertibleToFloat | None = None, spPr: GraphicalProperties | None = None, extLst: Unused = None, ) -> None: ... diff --git a/stubs/openpyxl/openpyxl/chart/label.pyi b/stubs/openpyxl/openpyxl/chart/label.pyi index 0473048ad..9d736eb68 100644 --- a/stubs/openpyxl/openpyxl/chart/label.pyi +++ b/stubs/openpyxl/openpyxl/chart/label.pyi @@ -1,46 +1,49 @@ from _typeshed import Incomplete, Unused from abc import abstractmethod from typing import ClassVar -from typing_extensions import Literal +from typing_extensions import Literal, TypeAlias from openpyxl.chart.shapes import GraphicalProperties from openpyxl.chart.text import RichText -from openpyxl.descriptors.base import Alias, Typed +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.serialisable import Serialisable as Serialisable +_DataLabelBaseDLblPos: TypeAlias = Literal["bestFit", "b", "ctr", "inBase", "inEnd", "l", "outEnd", "r", "t"] + class _DataLabelBase(Serialisable): - numFmt: Incomplete + numFmt: NestedString[Literal[True]] spPr: Typed[GraphicalProperties, Literal[True]] graphicalProperties: Alias txPr: Typed[RichText, Literal[True]] textProperties: Alias - dLblPos: Incomplete + dLblPos: NestedNoneSet[_DataLabelBaseDLblPos] position: Alias - showLegendKey: Incomplete - showVal: Incomplete - showCatName: Incomplete - showSerName: Incomplete - showPercent: Incomplete - showBubbleSize: Incomplete - showLeaderLines: Incomplete - separator: Incomplete + showLegendKey: NestedBool[Literal[True]] + showVal: NestedBool[Literal[True]] + showCatName: NestedBool[Literal[True]] + showSerName: NestedBool[Literal[True]] + showPercent: NestedBool[Literal[True]] + showBubbleSize: NestedBool[Literal[True]] + showLeaderLines: NestedBool[Literal[True]] + separator: NestedString[Literal[True]] extLst: Typed[ExtensionList, Literal[True]] __elements__: ClassVar[tuple[str, ...]] def __init__( self, - numFmt: Incomplete | None = None, + numFmt: object = None, spPr: GraphicalProperties | None = None, txPr: RichText | None = None, - dLblPos: Incomplete | None = None, - showLegendKey: Incomplete | None = None, - showVal: Incomplete | None = None, - showCatName: Incomplete | None = None, - showSerName: Incomplete | None = None, - showPercent: Incomplete | None = None, - showBubbleSize: Incomplete | None = None, - showLeaderLines: Incomplete | None = None, - separator: Incomplete | None = None, + dLblPos: _NestedNoneSetParam[_DataLabelBaseDLblPos] = None, + showLegendKey: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, + showVal: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, + showCatName: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, + showSerName: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, + showPercent: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, + showBubbleSize: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, + showLeaderLines: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, + separator: object = None, extLst: Unused = None, ) -> None: ... @property @@ -49,7 +52,7 @@ class _DataLabelBase(Serialisable): class DataLabel(_DataLabelBase): tagname: str - idx: Incomplete + idx: NestedInteger[Literal[False]] numFmt: Incomplete spPr: Incomplete txPr: Incomplete @@ -64,12 +67,12 @@ class DataLabel(_DataLabelBase): separator: Incomplete extLst: Incomplete __elements__: ClassVar[tuple[str, ...]] - def __init__(self, idx: int = 0, **kw) -> None: ... + def __init__(self, idx: _HasTagAndGet[_ConvertibleToInt] | _ConvertibleToInt = 0, **kw) -> None: ... class DataLabelList(_DataLabelBase): tagname: str dLbl: Incomplete - delete: Incomplete + delete: NestedBool[Literal[True]] numFmt: Incomplete spPr: Incomplete txPr: Incomplete @@ -84,4 +87,6 @@ class DataLabelList(_DataLabelBase): separator: Incomplete extLst: Incomplete __elements__: ClassVar[tuple[str, ...]] - def __init__(self, dLbl=(), delete: Incomplete | None = None, **kw) -> None: ... + def __init__( + self, dLbl=(), delete: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, **kw + ) -> None: ... diff --git a/stubs/openpyxl/openpyxl/chart/layout.pyi b/stubs/openpyxl/openpyxl/chart/layout.pyi index 0d9b6a9cc..423c62311 100644 --- a/stubs/openpyxl/openpyxl/chart/layout.pyi +++ b/stubs/openpyxl/openpyxl/chart/layout.pyi @@ -1,37 +1,41 @@ -from _typeshed import Incomplete, Unused +from _typeshed import Unused from typing import ClassVar -from typing_extensions import Literal +from typing_extensions import Literal, TypeAlias -from openpyxl.descriptors.base import Alias, Typed +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.serialisable import Serialisable +_ManualLayoutMode: TypeAlias = Literal["edge", "factor"] +_ManualLayoutLayoutTarget: TypeAlias = Literal["inner", "outer"] + class ManualLayout(Serialisable): tagname: str - layoutTarget: Incomplete - xMode: Incomplete - yMode: Incomplete - wMode: Incomplete - hMode: Incomplete - x: Incomplete - y: Incomplete - w: Incomplete + layoutTarget: NestedNoneSet[_ManualLayoutLayoutTarget] + xMode: NestedNoneSet[_ManualLayoutMode] + yMode: NestedNoneSet[_ManualLayoutMode] + wMode: NestedSet[_ManualLayoutMode] + hMode: NestedSet[_ManualLayoutMode] + x: NestedMinMax[float, Literal[True]] + y: NestedMinMax[float, Literal[True]] + w: NestedMinMax[float, Literal[True]] width: Alias - h: Incomplete + h: NestedMinMax[float, Literal[True]] height: Alias extLst: Typed[ExtensionList, Literal[True]] __elements__: ClassVar[tuple[str, ...]] def __init__( self, - layoutTarget: Incomplete | None = None, - xMode: Incomplete | None = None, - yMode: Incomplete | None = None, - wMode: str = "factor", - hMode: str = "factor", - x: Incomplete | None = None, - y: Incomplete | None = None, - w: Incomplete | None = None, - h: Incomplete | None = None, + layoutTarget: _NestedNoneSetParam[_ManualLayoutLayoutTarget] = None, + xMode: _NestedNoneSetParam[_ManualLayoutMode] = None, + yMode: _NestedNoneSetParam[_ManualLayoutMode] = None, + wMode: _HasTagAndGet[_ManualLayoutMode] | _ManualLayoutMode = "factor", + hMode: _HasTagAndGet[_ManualLayoutMode] | _ManualLayoutMode = "factor", + x: _HasTagAndGet[_ConvertibleToFloat | None] | _ConvertibleToFloat | None = None, + y: _HasTagAndGet[_ConvertibleToFloat | None] | _ConvertibleToFloat | None = None, + w: _HasTagAndGet[_ConvertibleToFloat | None] | _ConvertibleToFloat | None = None, + h: _HasTagAndGet[_ConvertibleToFloat | None] | _ConvertibleToFloat | None = None, extLst: Unused = None, ) -> None: ... diff --git a/stubs/openpyxl/openpyxl/chart/legend.pyi b/stubs/openpyxl/openpyxl/chart/legend.pyi index e7dfc21cf..4b371178f 100644 --- a/stubs/openpyxl/openpyxl/chart/legend.pyi +++ b/stubs/openpyxl/openpyxl/chart/legend.pyi @@ -1,30 +1,39 @@ from _typeshed import Incomplete, Unused from typing import ClassVar -from typing_extensions import Literal +from typing_extensions import Literal, TypeAlias 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 +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.serialisable import Serialisable +_LegendLegendPos: TypeAlias = Literal["b", "tr", "l", "r", "t"] + class LegendEntry(Serialisable): tagname: str - idx: Incomplete - delete: Incomplete + idx: NestedInteger[Literal[False]] + delete: NestedBool[Literal[False]] txPr: Typed[RichText, Literal[True]] extLst: Typed[ExtensionList, Literal[True]] __elements__: ClassVar[tuple[str, ...]] - def __init__(self, idx: int = 0, delete: bool = False, txPr: RichText | None = None, extLst: Unused = None) -> None: ... + def __init__( + self, + idx: _HasTagAndGet[_ConvertibleToInt] | _ConvertibleToInt = 0, + delete: _HasTagAndGet[_ConvertibleToBool] | _ConvertibleToBool = False, + txPr: RichText | None = None, + extLst: Unused = None, + ) -> None: ... class Legend(Serialisable): tagname: str - legendPos: Incomplete + legendPos: NestedSet[_LegendLegendPos] position: Alias legendEntry: Incomplete layout: Typed[Layout, Literal[True]] - overlay: Incomplete + overlay: NestedBool[Literal[True]] spPr: Typed[GraphicalProperties, Literal[True]] graphicalProperties: Alias txPr: Typed[RichText, Literal[True]] @@ -33,10 +42,10 @@ class Legend(Serialisable): __elements__: ClassVar[tuple[str, ...]] def __init__( self, - legendPos: str = "r", + legendPos: _HasTagAndGet[_LegendLegendPos] | _LegendLegendPos = "r", legendEntry=(), layout: Layout | None = None, - overlay: Incomplete | None = None, + overlay: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, spPr: GraphicalProperties | None = None, txPr: RichText | None = None, extLst: Unused = None, diff --git a/stubs/openpyxl/openpyxl/chart/line_chart.pyi b/stubs/openpyxl/openpyxl/chart/line_chart.pyi index 122b13fd7..09e4be4a4 100644 --- a/stubs/openpyxl/openpyxl/chart/line_chart.pyi +++ b/stubs/openpyxl/openpyxl/chart/line_chart.pyi @@ -1,19 +1,22 @@ from _typeshed import Incomplete, Unused from abc import abstractmethod from typing import ClassVar -from typing_extensions import Literal +from typing_extensions import Literal, TypeAlias from openpyxl.chart.axis import ChartLines, NumericAxis, _BaseAxis from openpyxl.chart.label import DataLabelList from openpyxl.chart.updown_bars import UpDownBars -from openpyxl.descriptors.base import Alias, Typed +from openpyxl.descriptors.base import Alias, Typed, _ConvertibleToBool from openpyxl.descriptors.excel import ExtensionList +from openpyxl.descriptors.nested import NestedBool, NestedSet, _HasTagAndGet from ._chart import ChartBase +_LineChartBaseGrouping: TypeAlias = Literal["percentStacked", "standard", "stacked"] + class _LineChartBase(ChartBase): - grouping: Incomplete - varyColors: Incomplete + grouping: NestedSet[_LineChartBaseGrouping] + varyColors: NestedBool[Literal[True]] ser: Incomplete dLbls: Typed[DataLabelList, Literal[True]] dataLabels: Alias @@ -21,8 +24,8 @@ class _LineChartBase(ChartBase): __elements__: ClassVar[tuple[str, ...]] def __init__( self, - grouping: str = "standard", - varyColors: Incomplete | None = None, + grouping: _HasTagAndGet[_LineChartBaseGrouping] | _LineChartBaseGrouping = "standard", + varyColors: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, ser=(), dLbls: DataLabelList | None = None, dropLines: ChartLines | None = None, @@ -41,8 +44,8 @@ class LineChart(_LineChartBase): dropLines: Incomplete hiLowLines: Typed[ChartLines, Literal[True]] upDownBars: Typed[UpDownBars, Literal[True]] - marker: Incomplete - smooth: Incomplete + marker: NestedBool[Literal[True]] + smooth: NestedBool[Literal[True]] extLst: Typed[ExtensionList, Literal[True]] x_axis: Typed[_BaseAxis, Literal[False]] y_axis: Typed[NumericAxis, Literal[False]] @@ -51,8 +54,8 @@ class LineChart(_LineChartBase): self, hiLowLines: ChartLines | None = None, upDownBars: UpDownBars | None = None, - marker: Incomplete | None = None, - smooth: Incomplete | None = None, + marker: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, + smooth: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, extLst: Unused = None, **kw, ) -> None: ... @@ -67,8 +70,8 @@ class LineChart3D(_LineChartBase): gapDepth: Incomplete hiLowLines: Typed[ChartLines, Literal[True]] upDownBars: Typed[UpDownBars, Literal[True]] - marker: Incomplete - smooth: Incomplete + marker: NestedBool[Literal[True]] + smooth: NestedBool[Literal[True]] extLst: Typed[ExtensionList, Literal[True]] x_axis: Typed[ExtensionList, Literal[False]] y_axis: Typed[ExtensionList, Literal[False]] @@ -79,7 +82,7 @@ class LineChart3D(_LineChartBase): gapDepth: Incomplete | None = None, hiLowLines: ChartLines | None = None, upDownBars: UpDownBars | None = None, - marker: Incomplete | None = None, - smooth: Incomplete | None = None, + marker: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, + smooth: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, **kw, ) -> None: ... diff --git a/stubs/openpyxl/openpyxl/chart/marker.pyi b/stubs/openpyxl/openpyxl/chart/marker.pyi index 1a19cf824..5018da4ba 100644 --- a/stubs/openpyxl/openpyxl/chart/marker.pyi +++ b/stubs/openpyxl/openpyxl/chart/marker.pyi @@ -1,36 +1,41 @@ -from _typeshed import Incomplete, Unused +from _typeshed import Unused from typing import ClassVar -from typing_extensions import Literal +from typing_extensions import Literal, TypeAlias from openpyxl.chart.picture import PictureOptions from openpyxl.chart.shapes import GraphicalProperties -from openpyxl.descriptors.base import Alias, Typed +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.serialisable import Serialisable +_MarkerSymbol: TypeAlias = Literal[ + "circle", "dash", "diamond", "dot", "picture", "plus", "square", "star", "triangle", "x", "auto" +] + class Marker(Serialisable): tagname: str - symbol: Incomplete - size: Incomplete + symbol: NestedNoneSet[_MarkerSymbol] + size: NestedMinMax[float, Literal[True]] spPr: Typed[GraphicalProperties, Literal[True]] graphicalProperties: Alias extLst: Typed[ExtensionList, Literal[True]] __elements__: ClassVar[tuple[str, ...]] def __init__( self, - symbol: Incomplete | None = None, - size: Incomplete | None = None, + symbol: _NestedNoneSetParam[_MarkerSymbol] = None, + size: _HasTagAndGet[_ConvertibleToFloat | None] | _ConvertibleToFloat | None = None, spPr: GraphicalProperties | None = None, extLst: Unused = None, ) -> None: ... class DataPoint(Serialisable): tagname: str - idx: Incomplete - invertIfNegative: Incomplete + idx: NestedInteger[Literal[False]] + invertIfNegative: NestedBool[Literal[True]] marker: Typed[Marker, Literal[True]] - bubble3D: Incomplete - explosion: Incomplete + bubble3D: NestedBool[Literal[True]] + explosion: NestedInteger[Literal[True]] spPr: Typed[GraphicalProperties, Literal[True]] graphicalProperties: Alias pictureOptions: Typed[PictureOptions, Literal[True]] @@ -38,11 +43,11 @@ class DataPoint(Serialisable): __elements__: ClassVar[tuple[str, ...]] def __init__( self, - idx: Incomplete | None = None, - invertIfNegative: Incomplete | None = None, + idx: _HasTagAndGet[_ConvertibleToInt] | _ConvertibleToInt, + invertIfNegative: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, marker: Marker | None = None, - bubble3D: Incomplete | None = None, - explosion: Incomplete | None = None, + bubble3D: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, + explosion: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, spPr: GraphicalProperties | None = None, pictureOptions: PictureOptions | None = None, extLst: Unused = None, diff --git a/stubs/openpyxl/openpyxl/chart/picture.pyi b/stubs/openpyxl/openpyxl/chart/picture.pyi index ac155086d..53adc04b9 100644 --- a/stubs/openpyxl/openpyxl/chart/picture.pyi +++ b/stubs/openpyxl/openpyxl/chart/picture.pyi @@ -1,21 +1,25 @@ -from _typeshed import Incomplete 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.serialisable import Serialisable +_PictureOptionsPictureFormat: TypeAlias = Literal["stretch", "stack", "stackScale"] + class PictureOptions(Serialisable): tagname: str - applyToFront: Incomplete - applyToSides: Incomplete - applyToEnd: Incomplete - pictureFormat: Incomplete - pictureStackUnit: Incomplete + applyToFront: NestedBool[Literal[True]] + applyToSides: NestedBool[Literal[True]] + applyToEnd: NestedBool[Literal[True]] + pictureFormat: NestedNoneSet[_PictureOptionsPictureFormat] + pictureStackUnit: NestedFloat[Literal[True]] __elements__: ClassVar[tuple[str, ...]] def __init__( self, - applyToFront: Incomplete | None = None, - applyToSides: Incomplete | None = None, - applyToEnd: Incomplete | None = None, - pictureFormat: Incomplete | None = None, - pictureStackUnit: Incomplete | None = None, + applyToFront: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, + applyToSides: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, + applyToEnd: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, + pictureFormat: _NestedNoneSetParam[_PictureOptionsPictureFormat] = None, + pictureStackUnit: _HasTagAndGet[_ConvertibleToFloat | None] | _ConvertibleToFloat | None = None, ) -> None: ... diff --git a/stubs/openpyxl/openpyxl/chart/pie_chart.pyi b/stubs/openpyxl/openpyxl/chart/pie_chart.pyi index ca6774611..1325d9a39 100644 --- a/stubs/openpyxl/openpyxl/chart/pie_chart.pyi +++ b/stubs/openpyxl/openpyxl/chart/pie_chart.pyi @@ -1,23 +1,40 @@ from _typeshed import Incomplete, Unused from abc import abstractmethod from typing import ClassVar -from typing_extensions import Literal +from typing_extensions import Literal, TypeAlias from openpyxl.chart.axis import ChartLines from openpyxl.chart.label import DataLabelList -from openpyxl.descriptors.base import Alias, Typed +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.serialisable import Serialisable from ._chart import ChartBase +_ProjectedPieChartOfPieType: TypeAlias = Literal["pie", "bar"] +_ProjectedPieChartSplitType: TypeAlias = Literal["auto", "cust", "percent", "pos", "val"] + class _PieChartBase(ChartBase): - varyColors: Incomplete + varyColors: NestedBool[Literal[True]] ser: Incomplete dLbls: Typed[DataLabelList, Literal[True]] dataLabels: Alias __elements__: ClassVar[tuple[str, ...]] - def __init__(self, varyColors: bool = True, ser=(), dLbls: DataLabelList | None = None) -> None: ... + def __init__( + self, + varyColors: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = True, + ser=(), + dLbls: DataLabelList | None = None, + ) -> None: ... @property @abstractmethod def tagname(self) -> str: ... @@ -27,10 +44,12 @@ class PieChart(_PieChartBase): varyColors: Incomplete ser: Incomplete dLbls: Incomplete - firstSliceAng: Incomplete + firstSliceAng: NestedMinMax[float, Literal[False]] extLst: Typed[ExtensionList, Literal[True]] __elements__: ClassVar[tuple[str, ...]] - def __init__(self, firstSliceAng: int = 0, extLst: Unused = None, **kw) -> None: ... + def __init__( + self, firstSliceAng: _HasTagAndGet[_ConvertibleToFloat] | _ConvertibleToFloat = 0, extLst: Unused = None, **kw + ) -> None: ... class PieChart3D(_PieChartBase): tagname: str @@ -45,11 +64,17 @@ class DoughnutChart(_PieChartBase): varyColors: Incomplete ser: Incomplete dLbls: Incomplete - firstSliceAng: Incomplete - holeSize: Incomplete + firstSliceAng: NestedMinMax[float, Literal[False]] + holeSize: NestedMinMax[float, Literal[True]] extLst: Typed[ExtensionList, Literal[True]] __elements__: ClassVar[tuple[str, ...]] - def __init__(self, firstSliceAng: int = 0, holeSize: int = 10, extLst: Unused = None, **kw) -> None: ... + def __init__( + self, + firstSliceAng: _HasTagAndGet[_ConvertibleToFloat] | _ConvertibleToFloat = 0, + holeSize: _HasTagAndGet[_ConvertibleToFloat | None] | _ConvertibleToFloat | None = 10, + extLst: Unused = None, + **kw, + ) -> None: ... class CustomSplit(Serialisable): tagname: str @@ -62,25 +87,25 @@ class ProjectedPieChart(_PieChartBase): varyColors: Incomplete ser: Incomplete dLbls: Incomplete - ofPieType: Incomplete + ofPieType: NestedSet[_ProjectedPieChartOfPieType] type: Alias gapWidth: Incomplete - splitType: Incomplete - splitPos: Incomplete + splitType: NestedNoneSet[_ProjectedPieChartSplitType] + splitPos: NestedFloat[Literal[True]] custSplit: Typed[CustomSplit, Literal[True]] - secondPieSize: Incomplete + secondPieSize: NestedMinMax[float, Literal[True]] serLines: Typed[ChartLines, Literal[True]] join_lines: Alias extLst: Typed[ExtensionList, Literal[True]] __elements__: ClassVar[tuple[str, ...]] def __init__( self, - ofPieType: str = "pie", + ofPieType: _HasTagAndGet[_ProjectedPieChartOfPieType] | _ProjectedPieChartOfPieType = "pie", gapWidth: Incomplete | None = None, - splitType: str = "auto", - splitPos: Incomplete | None = None, + splitType: _NestedNoneSetParam[_ProjectedPieChartSplitType] = "auto", + splitPos: _HasTagAndGet[_ConvertibleToFloat | None] | _ConvertibleToFloat | None = None, custSplit: CustomSplit | None = None, - secondPieSize: int = 75, + secondPieSize: _HasTagAndGet[_ConvertibleToFloat | None] | _ConvertibleToFloat | None = 75, serLines: ChartLines | None = None, extLst: Unused = None, **kw, diff --git a/stubs/openpyxl/openpyxl/chart/pivot.pyi b/stubs/openpyxl/openpyxl/chart/pivot.pyi index 2d9ae8111..1c70c0e16 100644 --- a/stubs/openpyxl/openpyxl/chart/pivot.pyi +++ b/stubs/openpyxl/openpyxl/chart/pivot.pyi @@ -1,26 +1,34 @@ -from _typeshed import Incomplete, Unused -from typing import ClassVar +from _typeshed import Unused +from typing import ClassVar, overload from typing_extensions import Literal from openpyxl.chart.label import DataLabel as _DataLabel from openpyxl.chart.marker import Marker from openpyxl.chart.shapes import GraphicalProperties from openpyxl.chart.text import RichText -from openpyxl.descriptors.base import Alias, Typed +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.serialisable import Serialisable class PivotSource(Serialisable): tagname: str - name: Incomplete - fmtId: Incomplete + name: NestedText[str, Literal[False]] + fmtId: NestedInteger[Literal[False]] extLst: Typed[ExtensionList, Literal[True]] __elements__: ClassVar[tuple[str, ...]] - def __init__(self, name: str | None = None, fmtId: Incomplete | None = None, extLst: Unused = None) -> None: ... + @overload + def __init__( + self, name: object, fmtId: _HasTagAndGet[_ConvertibleToInt] | _ConvertibleToInt, extLst: Unused = None + ) -> None: ... + @overload + def __init__( + self, name: object = None, *, fmtId: _HasTagAndGet[_ConvertibleToInt] | _ConvertibleToInt, extLst: Unused = None + ) -> None: ... class PivotFormat(Serialisable): tagname: str - idx: Incomplete + idx: NestedInteger[Literal[False]] spPr: Typed[GraphicalProperties, Literal[True]] graphicalProperties: Alias txPr: Typed[RichText, Literal[True]] @@ -32,7 +40,7 @@ class PivotFormat(Serialisable): __elements__: ClassVar[tuple[str, ...]] def __init__( self, - idx: int = 0, + idx: _HasTagAndGet[_ConvertibleToInt] | _ConvertibleToInt = 0, spPr: GraphicalProperties | None = None, txPr: RichText | None = None, marker: Marker | None = None, diff --git a/stubs/openpyxl/openpyxl/chart/plotarea.pyi b/stubs/openpyxl/openpyxl/chart/plotarea.pyi index ef67d2b57..8b941d0e4 100644 --- a/stubs/openpyxl/openpyxl/chart/plotarea.pyi +++ b/stubs/openpyxl/openpyxl/chart/plotarea.pyi @@ -5,16 +5,17 @@ from typing_extensions import Literal 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 +from openpyxl.descriptors.base import Alias, Typed, _ConvertibleToBool from openpyxl.descriptors.excel import ExtensionList +from openpyxl.descriptors.nested import NestedBool, _HasTagAndGet from openpyxl.descriptors.serialisable import Serialisable class DataTable(Serialisable): tagname: str - showHorzBorder: Incomplete - showVertBorder: Incomplete - showOutline: Incomplete - showKeys: Incomplete + showHorzBorder: NestedBool[Literal[True]] + showVertBorder: NestedBool[Literal[True]] + showOutline: NestedBool[Literal[True]] + showKeys: NestedBool[Literal[True]] spPr: Typed[GraphicalProperties, Literal[True]] graphicalProperties: Alias txPr: Typed[RichText, Literal[True]] @@ -22,10 +23,10 @@ class DataTable(Serialisable): __elements__: ClassVar[tuple[str, ...]] def __init__( self, - showHorzBorder: Incomplete | None = None, - showVertBorder: Incomplete | None = None, - showOutline: Incomplete | None = None, - showKeys: Incomplete | None = None, + showHorzBorder: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, + showVertBorder: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, + showOutline: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, + showKeys: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, spPr: GraphicalProperties | None = None, txPr: RichText | None = None, extLst: Unused = None, diff --git a/stubs/openpyxl/openpyxl/chart/radar_chart.pyi b/stubs/openpyxl/openpyxl/chart/radar_chart.pyi index 93cda0001..2746e34a3 100644 --- a/stubs/openpyxl/openpyxl/chart/radar_chart.pyi +++ b/stubs/openpyxl/openpyxl/chart/radar_chart.pyi @@ -1,19 +1,22 @@ from _typeshed import Incomplete, Unused from typing import ClassVar -from typing_extensions import Literal +from typing_extensions import Literal, TypeAlias from openpyxl.chart.axis import NumericAxis, TextAxis from openpyxl.chart.label import DataLabelList -from openpyxl.descriptors.base import Alias, Typed +from openpyxl.descriptors.base import Alias, Typed, _ConvertibleToBool from openpyxl.descriptors.excel import ExtensionList +from openpyxl.descriptors.nested import NestedBool, NestedSet, _HasTagAndGet from ._chart import ChartBase +_RadarChartRadarStyle: TypeAlias = Literal["standard", "marker", "filled"] + class RadarChart(ChartBase): tagname: str - radarStyle: Incomplete + radarStyle: NestedSet[_RadarChartRadarStyle] type: Alias - varyColors: Incomplete + varyColors: NestedBool[Literal[True]] ser: Incomplete dLbls: Typed[DataLabelList, Literal[True]] dataLabels: Alias @@ -23,8 +26,8 @@ class RadarChart(ChartBase): __elements__: ClassVar[tuple[str, ...]] def __init__( self, - radarStyle: str = "standard", - varyColors: Incomplete | None = None, + radarStyle: _HasTagAndGet[_RadarChartRadarStyle] | _RadarChartRadarStyle = "standard", + varyColors: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, ser=(), dLbls: DataLabelList | None = None, extLst: Unused = None, diff --git a/stubs/openpyxl/openpyxl/chart/scatter_chart.pyi b/stubs/openpyxl/openpyxl/chart/scatter_chart.pyi index 2aebe5b13..b4233e3d9 100644 --- a/stubs/openpyxl/openpyxl/chart/scatter_chart.pyi +++ b/stubs/openpyxl/openpyxl/chart/scatter_chart.pyi @@ -1,18 +1,21 @@ from _typeshed import Incomplete, Unused from typing import ClassVar -from typing_extensions import Literal +from typing_extensions import Literal, TypeAlias from openpyxl.chart.axis import NumericAxis, TextAxis from openpyxl.chart.label import DataLabelList -from openpyxl.descriptors.base import Alias, Typed +from openpyxl.descriptors.base import Alias, Typed, _ConvertibleToBool from openpyxl.descriptors.excel import ExtensionList +from openpyxl.descriptors.nested import NestedBool, NestedNoneSet, _HasTagAndGet, _NestedNoneSetParam from ._chart import ChartBase as ChartBase +_ScatterChartScatterStyle: TypeAlias = Literal["line", "lineMarker", "marker", "smooth", "smoothMarker"] + class ScatterChart(ChartBase): tagname: str - scatterStyle: Incomplete - varyColors: Incomplete + scatterStyle: NestedNoneSet[_ScatterChartScatterStyle] + varyColors: NestedBool[Literal[True]] ser: Incomplete dLbls: Typed[DataLabelList, Literal[True]] dataLabels: Alias @@ -22,8 +25,8 @@ class ScatterChart(ChartBase): __elements__: ClassVar[tuple[str, ...]] def __init__( self, - scatterStyle: Incomplete | None = None, - varyColors: Incomplete | None = None, + scatterStyle: _NestedNoneSetParam[_ScatterChartScatterStyle] = None, + varyColors: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, ser=(), dLbls: DataLabelList | None = None, extLst: Unused = None, diff --git a/stubs/openpyxl/openpyxl/chart/series.pyi b/stubs/openpyxl/openpyxl/chart/series.pyi index 7dcb7b771..b80037153 100644 --- a/stubs/openpyxl/openpyxl/chart/series.pyi +++ b/stubs/openpyxl/openpyxl/chart/series.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete, Unused from typing import ClassVar -from typing_extensions import Literal +from typing_extensions import Literal, TypeAlias from openpyxl.chart.data_source import AxDataSource, NumDataSource, StrRef from openpyxl.chart.error_bar import ErrorBars @@ -9,24 +9,27 @@ from openpyxl.chart.marker import Marker from openpyxl.chart.picture import PictureOptions from openpyxl.chart.shapes import GraphicalProperties from openpyxl.chart.trendline import Trendline -from openpyxl.descriptors.base import Alias, Typed +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.serialisable import Serialisable +_SeriesShape: TypeAlias = Literal["cone", "coneToMax", "box", "cylinder", "pyramid", "pyramidToMax"] + attribute_mapping: Incomplete class SeriesLabel(Serialisable): tagname: str strRef: Typed[StrRef, Literal[True]] - v: Incomplete + v: NestedText[str, Literal[True]] value: Alias __elements__: ClassVar[tuple[str, ...]] - def __init__(self, strRef: StrRef | None = None, v: Incomplete | None = None) -> None: ... + def __init__(self, strRef: StrRef | None = None, v: object = None) -> None: ... class Series(Serialisable): tagname: str - idx: Incomplete - order: Incomplete + idx: NestedInteger[Literal[False]] + order: NestedInteger[Literal[False]] tx: Typed[SeriesLabel, Literal[True]] title: Alias spPr: Typed[GraphicalProperties, Literal[True]] @@ -42,21 +45,21 @@ class Series(Serialisable): identifiers: Alias val: Typed[NumDataSource, Literal[True]] extLst: Typed[ExtensionList, Literal[True]] - invertIfNegative: Incomplete - shape: Incomplete + invertIfNegative: NestedBool[Literal[True]] + shape: NestedNoneSet[_SeriesShape] xVal: Typed[AxDataSource, Literal[True]] yVal: Typed[NumDataSource, Literal[True]] bubbleSize: Typed[NumDataSource, Literal[True]] zVal: Alias - bubble3D: Incomplete + bubble3D: NestedBool[Literal[True]] marker: Typed[Marker, Literal[True]] - smooth: Incomplete - explosion: Incomplete + smooth: NestedBool[Literal[True]] + explosion: NestedInteger[Literal[True]] __elements__: ClassVar[tuple[str, ...]] def __init__( self, - idx: int = 0, - order: int = 0, + idx: _HasTagAndGet[_ConvertibleToInt] | _ConvertibleToInt = 0, + order: _HasTagAndGet[_ConvertibleToInt] | _ConvertibleToInt = 0, tx: SeriesLabel | None = None, spPr: GraphicalProperties | None = None, pictureOptions: PictureOptions | None = None, @@ -66,15 +69,15 @@ class Series(Serialisable): errBars: ErrorBars | None = None, cat: AxDataSource | None = None, val: NumDataSource | None = None, - invertIfNegative: Incomplete | None = None, - shape: Incomplete | None = None, + invertIfNegative: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, + shape: _NestedNoneSetParam[_SeriesShape] = None, xVal: AxDataSource | None = None, yVal: NumDataSource | None = None, bubbleSize: NumDataSource | None = None, - bubble3D: Incomplete | None = None, + bubble3D: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, marker: Marker | None = None, - smooth: Incomplete | None = None, - explosion: Incomplete | None = None, + smooth: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, + explosion: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, extLst: Unused = None, ) -> None: ... def to_tree(self, tagname: Incomplete | None = None, idx: Incomplete | None = None): ... # type: ignore[override] diff --git a/stubs/openpyxl/openpyxl/chart/shapes.pyi b/stubs/openpyxl/openpyxl/chart/shapes.pyi index 11f1cb588..d9d57a2f5 100644 --- a/stubs/openpyxl/openpyxl/chart/shapes.pyi +++ b/stubs/openpyxl/openpyxl/chart/shapes.pyi @@ -2,7 +2,8 @@ from _typeshed import Incomplete, Unused from typing import ClassVar from typing_extensions import Literal, TypeAlias -from openpyxl.descriptors.base import Alias, NoneSet, Typed +from openpyxl.descriptors.base import Alias, NoneSet, Typed, _ConvertibleToBool +from openpyxl.descriptors.nested import EmptyTag, _HasTagAndGet from openpyxl.descriptors.serialisable import Serialisable from openpyxl.drawing.fill import GradientFillProperties, PatternFillProperties from openpyxl.drawing.geometry import CustomGeometry2D, PresetGeometry2D, Scene3D, Shape3D, Transform2D @@ -19,7 +20,7 @@ class GraphicalProperties(Serialisable): transform: Alias custGeom: Typed[CustomGeometry2D, Literal[True]] prstGeom: Typed[PresetGeometry2D, Literal[True]] - noFill: Incomplete + noFill: EmptyTag[Literal[False]] solidFill: Incomplete gradFill: Typed[GradientFillProperties, Literal[True]] pattFill: Typed[PatternFillProperties, Literal[True]] @@ -34,7 +35,7 @@ class GraphicalProperties(Serialisable): self, bwMode: _GraphicalPropertiesBwMode | Literal["none"] | None = None, xfrm: Transform2D | None = None, - noFill: Incomplete | None = None, + noFill: _HasTagAndGet[_ConvertibleToBool] | _ConvertibleToBool = None, solidFill: Incomplete | None = None, gradFill: GradientFillProperties | None = None, pattFill: PatternFillProperties | None = None, diff --git a/stubs/openpyxl/openpyxl/chart/surface_chart.pyi b/stubs/openpyxl/openpyxl/chart/surface_chart.pyi index ea9d2a3bb..f4fc099bd 100644 --- a/stubs/openpyxl/openpyxl/chart/surface_chart.pyi +++ b/stubs/openpyxl/openpyxl/chart/surface_chart.pyi @@ -5,8 +5,9 @@ from typing_extensions import Literal from openpyxl.chart.axis import NumericAxis, SeriesAxis, TextAxis from openpyxl.chart.shapes import GraphicalProperties -from openpyxl.descriptors.base import Alias, Typed +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.serialisable import Serialisable from ._3d import _3DBase @@ -14,11 +15,13 @@ from ._chart import ChartBase class BandFormat(Serialisable): tagname: str - idx: Incomplete + idx: NestedInteger[Literal[False]] spPr: Typed[GraphicalProperties, Literal[True]] graphicalProperties: Alias __elements__: ClassVar[tuple[str, ...]] - def __init__(self, idx: int = 0, spPr: GraphicalProperties | None = None) -> None: ... + def __init__( + self, idx: _HasTagAndGet[_ConvertibleToInt] | _ConvertibleToInt = 0, spPr: GraphicalProperties | None = None + ) -> None: ... class BandFormatList(Serialisable): tagname: str @@ -27,11 +30,17 @@ class BandFormatList(Serialisable): def __init__(self, bandFmt=()) -> None: ... class _SurfaceChartBase(ChartBase): - wireframe: Incomplete + wireframe: NestedBool[Literal[True]] ser: Incomplete bandFmts: Typed[BandFormatList, Literal[True]] __elements__: ClassVar[tuple[str, ...]] - def __init__(self, wireframe: Incomplete | None = None, ser=(), bandFmts: BandFormatList | None = None, **kw) -> None: ... + def __init__( + self, + wireframe: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, + ser=(), + bandFmts: BandFormatList | None = None, + **kw, + ) -> None: ... @property @abstractmethod def tagname(self) -> str: ... diff --git a/stubs/openpyxl/openpyxl/chart/title.pyi b/stubs/openpyxl/openpyxl/chart/title.pyi index 49c4f8efd..c9e829790 100644 --- a/stubs/openpyxl/openpyxl/chart/title.pyi +++ b/stubs/openpyxl/openpyxl/chart/title.pyi @@ -6,8 +6,9 @@ from openpyxl.chart.layout import Layout from openpyxl.chart.shapes import GraphicalProperties from openpyxl.chart.text import RichText, Text from openpyxl.descriptors import Strict, Typed -from openpyxl.descriptors.base import Alias +from openpyxl.descriptors.base import Alias, _ConvertibleToBool from openpyxl.descriptors.excel import ExtensionList +from openpyxl.descriptors.nested import NestedBool, _HasTagAndGet from openpyxl.descriptors.serialisable import Serialisable class Title(Serialisable): @@ -15,7 +16,7 @@ class Title(Serialisable): tx: Typed[Text, Literal[True]] text: Alias layout: Typed[Layout, Literal[True]] - overlay: Incomplete + overlay: NestedBool[Literal[True]] spPr: Typed[GraphicalProperties, Literal[True]] graphicalProperties: Alias txPr: Typed[RichText, Literal[True]] @@ -26,7 +27,7 @@ class Title(Serialisable): self, tx: Text | None = None, layout: Layout | None = None, - overlay: Incomplete | None = None, + overlay: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, spPr: GraphicalProperties | None = None, txPr: RichText | None = None, extLst: Unused = None, diff --git a/stubs/openpyxl/openpyxl/chart/trendline.pyi b/stubs/openpyxl/openpyxl/chart/trendline.pyi index aff6c9473..aa31894ad 100644 --- a/stubs/openpyxl/openpyxl/chart/trendline.pyi +++ b/stubs/openpyxl/openpyxl/chart/trendline.pyi @@ -1,15 +1,18 @@ -from _typeshed import Incomplete, Unused +from _typeshed import Unused from typing import ClassVar -from typing_extensions import Literal +from typing_extensions import Literal, TypeAlias from openpyxl.chart.data_source import NumFmt from openpyxl.chart.layout import Layout from openpyxl.chart.shapes import GraphicalProperties from openpyxl.chart.text import RichText, Text -from openpyxl.descriptors.base import Alias, String, Typed +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.serialisable import Serialisable +_TrendlineTrendlineType: TypeAlias = Literal["exp", "linear", "log", "movingAvg", "poly", "power"] + class TrendlineLabel(Serialisable): tagname: str layout: Typed[Layout, Literal[True]] @@ -36,14 +39,14 @@ class Trendline(Serialisable): name: String[Literal[True]] spPr: Typed[ExtensionList, Literal[True]] graphicalProperties: Alias - trendlineType: Incomplete - order: Incomplete - period: Incomplete - forward: Incomplete - backward: Incomplete - intercept: Incomplete - dispRSqr: Incomplete - dispEq: Incomplete + trendlineType: NestedSet[_TrendlineTrendlineType] + order: NestedInteger[Literal[True]] + period: NestedInteger[Literal[True]] + forward: NestedFloat[Literal[True]] + backward: NestedFloat[Literal[True]] + intercept: NestedFloat[Literal[True]] + dispRSqr: NestedBool[Literal[True]] + dispEq: NestedBool[Literal[True]] trendlineLbl: Typed[ExtensionList, Literal[True]] extLst: Typed[ExtensionList, Literal[True]] __elements__: ClassVar[tuple[str, ...]] @@ -51,14 +54,14 @@ class Trendline(Serialisable): self, name: str | None = None, spPr: ExtensionList | None = None, - trendlineType: str = "linear", - order: Incomplete | None = None, - period: Incomplete | None = None, - forward: Incomplete | None = None, - backward: Incomplete | None = None, - intercept: Incomplete | None = None, - dispRSqr: Incomplete | None = None, - dispEq: Incomplete | None = None, + trendlineType: _HasTagAndGet[_TrendlineTrendlineType] | _TrendlineTrendlineType = "linear", + order: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + period: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + forward: _HasTagAndGet[_ConvertibleToFloat | None] | _ConvertibleToFloat | None = None, + backward: _HasTagAndGet[_ConvertibleToFloat | None] | _ConvertibleToFloat | None = None, + intercept: _HasTagAndGet[_ConvertibleToFloat | None] | _ConvertibleToFloat | None = None, + dispRSqr: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, + dispEq: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, trendlineLbl: ExtensionList | None = None, extLst: Unused = None, ) -> None: ... diff --git a/stubs/openpyxl/openpyxl/descriptors/base.pyi b/stubs/openpyxl/openpyxl/descriptors/base.pyi index 5fa2dac33..37f59fed2 100644 --- a/stubs/openpyxl/openpyxl/descriptors/base.pyi +++ b/stubs/openpyxl/openpyxl/descriptors/base.pyi @@ -265,7 +265,7 @@ class Bool(Convertible[bool, _N]): @overload def __init__(self: Bool[Literal[False]], name: str | None = None, *, allow_none: Literal[False] = False) -> None: ... def __set__( # type:ignore[override] # Different restrictions - self: Bool[Literal[True]], instance: Serialisable | Strict, value: _ConvertibleToBool | None + self, instance: Serialisable | Strict, value: _ConvertibleToBool ) -> None: ... class String(Typed[str, _N]): diff --git a/stubs/openpyxl/openpyxl/descriptors/nested.pyi b/stubs/openpyxl/openpyxl/descriptors/nested.pyi index 2c0643e5d..313efcfb9 100644 --- a/stubs/openpyxl/openpyxl/descriptors/nested.pyi +++ b/stubs/openpyxl/openpyxl/descriptors/nested.pyi @@ -1,41 +1,271 @@ -from _typeshed import Incomplete +from _typeshed import Incomplete, Unused +from collections.abc import Callable +from typing import Any, ClassVar, NoReturn, Protocol, TypeVar, overload +from typing_extensions import Literal, TypeAlias from openpyxl.descriptors import Strict from openpyxl.descriptors.base import Bool, Convertible, Descriptor, Float, Integer, MinMax, NoneSet, Set, String from openpyxl.descriptors.serialisable import Serialisable +from openpyxl.drawing.fill import Blip +from openpyxl.xml.functions import Element -# NOTE: # type: ignore[misc]: Class does not reimplement the relevant methods, so runtime also has incompatible supertypes +from .base import _M, _N, _T, _ConvertibleToBool, _ConvertibleToFloat, _ConvertibleToInt, _ExpectedTypeParam -class Nested(Descriptor[Incomplete]): - nested: bool - attribute: str - def __set__(self, instance: Serialisable | Strict, value) -> None: ... - def from_tree(self, node): ... +_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 + +class Nested(Descriptor[_T]): + nested: ClassVar[Literal[True]] + attribute: ClassVar[str] + 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 to_tree( self, tagname: Incomplete | None = None, value: Incomplete | None = None, namespace: Incomplete | None = None - ): ... + ) -> Element: ... -class NestedValue(Nested, Convertible[Incomplete, Incomplete]): ... # type: ignore[misc] +class NestedValue(Nested[_T], Convertible[_T, _N]): # type: ignore[misc] + @overload + def __init__( + self: NestedValue[_T, Literal[True]], + name: str | None = None, + *, + expected_type: _ExpectedTypeParam[_T], + allow_none: Literal[True], + ) -> None: ... + @overload + def __init__( + self: NestedValue[_T, Literal[False]], + name: str | None = None, + *, + expected_type: _ExpectedTypeParam[_T], + allow_none: Literal[False] = False, + ) -> None: ... + @overload + def __get__(self: NestedValue[_T, Literal[True]], instance: Serialisable | Strict, cls: type | None = None) -> _T | None: ... + @overload + def __get__(self: NestedValue[_T, Literal[False]], instance: Serialisable | Strict, cls: type | None = None) -> _T: ... + # NOTE: It is currently impossible to make a generic based on the parameter type of another generic + # So we implement explicitely the types used internally + # str | Blip + @overload + def __set__( + self: NestedValue[str, bool] | NestedValue[Blip, bool], + instance: Serialisable | Strict, + value: object, # Not[None] when _N = False + ) -> None: ... + # bool + @overload + def __set__( + self: NestedValue[bool, bool], + instance: Serialisable | Strict, + value: _HasTagAndGet[_ConvertibleToBool] | _ConvertibleToBool, + ) -> None: ... + # int + @overload + def __set__( + self: NestedValue[int, Literal[True]], + instance: Serialisable | Strict, + value: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None, + ) -> None: ... + @overload + def __set__( + self: NestedValue[int, Literal[False]], + instance: Serialisable | Strict, + value: _HasTagAndGet[_ConvertibleToInt] | _ConvertibleToInt, + ) -> None: ... + # float + @overload + def __set__( + self: NestedValue[float, Literal[True]], + instance: Serialisable | Strict, + value: _HasTagAndGet[_ConvertibleToFloat | None] | _ConvertibleToFloat | None, + ) -> None: ... + @overload + def __set__( + self: NestedValue[float, Literal[False]], + instance: Serialisable | Strict, + value: _HasTagAndGet[_ConvertibleToFloat] | _ConvertibleToFloat, + ) -> None: ... + # Anything else + @overload + def __set__( + self: NestedValue[_T, Literal[True]], + instance: Serialisable | Strict, + value: _HasTagAndGet[_T | int | Any] | _T | int | Any | None, + ) -> None: ... -class NestedText(NestedValue): - def from_tree(self, node): ... +class NestedText(NestedValue[_T, _N]): + @overload + def __init__( + self: NestedText[_T, Literal[True]], + name: str | None = None, + *, + expected_type: _ExpectedTypeParam[_T], + allow_none: Literal[True], + ) -> None: ... + @overload + def __init__( + self: NestedText[_T, Literal[False]], + name: str | None = None, + *, + expected_type: _ExpectedTypeParam[_T], + allow_none: Literal[False] = False, + ) -> None: ... + @overload + def __get__(self: NestedText[_T, Literal[True]], instance: Serialisable | Strict, cls: type | None = None) -> _T | None: ... + @overload + def __get__(self: NestedText[_T, Literal[False]], instance: Serialisable | Strict, cls: type | None = None) -> _T: ... + # NOTE: It is currently impossible to make a generic based on the parameter type of another generic + # So we implement explicitely the types used internally + # str + @overload + def __set__( # type: ignore[misc] # Incompatible return type because of NoReturn + self: NestedValue[str, bool], instance: Serialisable | Strict, value: object # Not[None] when _N = False + ) -> None: ... + # int + @overload + def __set__( + self: NestedValue[int, Literal[True]], instance: Serialisable | Strict, value: _ConvertibleToInt | None + ) -> None: ... + @overload + def __set__(self: NestedValue[int, Literal[False]], instance: Serialisable | Strict, value: _ConvertibleToInt) -> None: ... + # If expected type (_T) is not str, it's impossible to use an Element as the value + @overload + def __set__(self: NestedValue[_T, Literal[True]], instance: Serialisable | Strict, value: _HasTagAndGet[Any]) -> NoReturn: ... + # Anything else + @overload + def __set__(self: NestedValue[_T, Literal[True]], instance: Serialisable | Strict, value: _T | int | Any | None) -> None: ... + def from_tree(self, node: _HasTagAndText) -> str: ... # type: ignore[override] def to_tree( self, tagname: Incomplete | None = None, value: Incomplete | None = None, namespace: Incomplete | None = None - ): ... + ) -> Element: ... -class NestedFloat(NestedValue, Float[Incomplete]): ... # type: ignore[misc] -class NestedInteger(NestedValue, Integer[Incomplete]): ... # type: ignore[misc] -class NestedString(NestedValue, String[Incomplete]): ... # type: ignore[misc] +class NestedFloat(NestedValue[float, _N], Float[_N]): # type: ignore[misc] + @overload + def __init__(self: NestedFloat[Literal[True]], name: str | None = None, *, allow_none: Literal[True]) -> None: ... + @overload + def __init__(self: NestedFloat[Literal[False]], name: str | None = None, *, allow_none: Literal[False] = False) -> None: ... -class NestedBool(NestedValue, Bool[Incomplete]): # type: ignore[misc] - def from_tree(self, node): ... +class NestedInteger(NestedValue[int, _N], Integer[_N]): # type: ignore[misc] + @overload + def __init__(self: NestedInteger[Literal[True]], name: str | None = None, *, allow_none: Literal[True]) -> None: ... + @overload + def __init__(self: NestedInteger[Literal[False]], name: str | None = None, *, allow_none: Literal[False] = False) -> None: ... -class NestedNoneSet(Nested, NoneSet[Incomplete]): ... -class NestedSet(Nested, Set[Incomplete]): ... -class NestedMinMax(Nested, MinMax[Incomplete, Incomplete]): ... # type: ignore[misc] +class NestedString(NestedValue[str, _N], String[_N]): # type: ignore[misc] + @overload + def __init__(self: NestedString[Literal[True]], name: str | None = None, *, allow_none: Literal[True]) -> None: ... + @overload + def __init__(self: NestedString[Literal[False]], name: str | None = None, *, allow_none: Literal[False] = False) -> None: ... -class EmptyTag(Nested, Bool[Incomplete]): # type: ignore[misc] - def from_tree(self, node): ... +class NestedBool(NestedValue[bool, _N], Bool[_N]): # type: ignore[misc] + @overload + def __init__(self: NestedBool[Literal[True]], name: str | None = None, *, allow_none: Literal[True]) -> None: ... + @overload + def __init__(self: NestedBool[Literal[False]], name: str | None = None, *, allow_none: Literal[False] = False) -> None: ... + 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 + +class NestedNoneSet(Nested[_T | None], NoneSet[_T]): # type: ignore[misc] + def __set__(self, instance: Serialisable | Strict, value: _NestedNoneSetParam[_T]) -> None: ... + +class NestedSet(Nested[_T], Set[_T]): ... + +class NestedMinMax(Nested[_M], MinMax[_M, _N]): # type: ignore[misc] + @overload + def __init__( + self: NestedMinMax[int, Literal[True]], + *, + expected_type: _ExpectedTypeParam[int], + allow_none: Literal[True], + min: float, + max: float, + ) -> None: ... + @overload + def __init__( + self: NestedMinMax[int, Literal[False]], + *, + expected_type: _ExpectedTypeParam[int], + allow_none: Literal[False] = False, + min: float, + max: float, + ) -> None: ... + # mypy can't infer type from `expected_type = float` (pyright can), so we have to add extra overloads + @overload + def __init__( + self: NestedMinMax[float, Literal[True]], + *, + expected_type: _ExpectedTypeParam[float] = ..., + allow_none: Literal[True], + min: float, + max: float, + ) -> None: ... + @overload + def __init__( + self: NestedMinMax[float, Literal[False]], + *, + expected_type: _ExpectedTypeParam[float] = ..., + allow_none: Literal[False] = False, + min: float, + max: float, + ) -> None: ... + @overload + def __get__(self: NestedMinMax[_M, Literal[True]], instance: Serialisable | Strict, cls: type | None = None) -> _M | None: ... + @overload + def __get__(self: NestedMinMax[_M, Literal[False]], instance: Serialisable | Strict, cls: type | None = None) -> _M: ... + @overload # type:ignore[override] # Different restrictions + def __set__( + self: NestedMinMax[int, Literal[True]], + instance: Serialisable | Strict, + value: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None, + ) -> None: ... + @overload + def __set__( + self: NestedMinMax[int, Literal[False]], + instance: Serialisable | Strict, + value: _HasTagAndGet[_ConvertibleToInt] | _ConvertibleToInt, + ) -> None: ... + @overload + def __set__( + self: NestedMinMax[float, Literal[True]], + instance: Serialisable | Strict, + value: _HasTagAndGet[_ConvertibleToFloat | None] | _ConvertibleToFloat | None, + ) -> None: ... + @overload + def __set__( + self: NestedMinMax[float, Literal[False]], + instance: Serialisable | Strict, + value: _HasTagAndGet[_ConvertibleToFloat] | _ConvertibleToFloat, + ) -> None: ... + +class EmptyTag(Nested[bool], Bool[_N]): # type: ignore[misc] + @overload + def __init__(self: EmptyTag[Literal[True]], name: str | None = None, *, allow_none: Literal[True]) -> None: ... + @overload + def __init__(self: EmptyTag[Literal[False]], name: str | None = None, *, allow_none: Literal[False] = False) -> None: ... + @overload + def __get__(self: EmptyTag[Literal[True]], instance: Serialisable | Strict, cls: type | None = None) -> bool | None: ... + @overload + def __get__(self: EmptyTag[Literal[False]], instance: Serialisable | Strict, cls: type | None = None) -> bool: ... + def __set__( # type:ignore[override] # Different restrictions + self, instance: Serialisable | Strict, value: _HasTagAndGet[_ConvertibleToBool] | _ConvertibleToBool + ) -> None: ... + def from_tree(self, node: Unused) -> Literal[True]: ... # type: ignore[override] # Actual overriden return type def to_tree( self, tagname: Incomplete | None = None, value: Incomplete | None = None, namespace: Incomplete | None = None - ): ... + ) -> Element: ... diff --git a/stubs/openpyxl/openpyxl/drawing/colors.pyi b/stubs/openpyxl/openpyxl/drawing/colors.pyi index 29bba5a90..8a1cb0858 100644 --- a/stubs/openpyxl/openpyxl/drawing/colors.pyi +++ b/stubs/openpyxl/openpyxl/drawing/colors.pyi @@ -3,8 +3,9 @@ from typing import ClassVar, overload from typing_extensions import Literal, TypeAlias from openpyxl.descriptors import Strict, Typed -from openpyxl.descriptors.base import Alias, Integer, MinMax, Set, _ConvertibleToFloat, _ConvertibleToInt +from openpyxl.descriptors.base import Alias, Integer, MinMax, Set, _ConvertibleToBool, _ConvertibleToFloat, _ConvertibleToInt from openpyxl.descriptors.excel import ExtensionList +from openpyxl.descriptors.nested import EmptyTag, NestedInteger, NestedNoneSet, NestedValue, _HasTagAndGet, _NestedNoneSetParam from openpyxl.descriptors.serialisable import Serialisable _ColorSetType: TypeAlias = Literal[ @@ -61,8 +62,200 @@ _SchemeColorVal: TypeAlias = Literal[ "dk2", "lt2", ] +_PresetColors: TypeAlias = Literal[ + "aliceBlue", + "antiqueWhite", + "aqua", + "aquamarine", + "azure", + "beige", + "bisque", + "black", + "blanchedAlmond", + "blue", + "blueViolet", + "brown", + "burlyWood", + "cadetBlue", + "chartreuse", + "chocolate", + "coral", + "cornflowerBlue", + "cornsilk", + "crimson", + "cyan", + "darkBlue", + "darkCyan", + "darkGoldenrod", + "darkGray", + "darkGrey", + "darkGreen", + "darkKhaki", + "darkMagenta", + "darkOliveGreen", + "darkOrange", + "darkOrchid", + "darkRed", + "darkSalmon", + "darkSeaGreen", + "darkSlateBlue", + "darkSlateGray", + "darkSlateGrey", + "darkTurquoise", + "darkViolet", + "dkBlue", + "dkCyan", + "dkGoldenrod", + "dkGray", + "dkGrey", + "dkGreen", + "dkKhaki", + "dkMagenta", + "dkOliveGreen", + "dkOrange", + "dkOrchid", + "dkRed", + "dkSalmon", + "dkSeaGreen", + "dkSlateBlue", + "dkSlateGray", + "dkSlateGrey", + "dkTurquoise", + "dkViolet", + "deepPink", + "deepSkyBlue", + "dimGray", + "dimGrey", + "dodgerBlue", + "firebrick", + "floralWhite", + "forestGreen", + "fuchsia", + "gainsboro", + "ghostWhite", + "gold", + "goldenrod", + "gray", + "grey", + "green", + "greenYellow", + "honeydew", + "hotPink", + "indianRed", + "indigo", + "ivory", + "khaki", + "lavender", + "lavenderBlush", + "lawnGreen", + "lemonChiffon", + "lightBlue", + "lightCoral", + "lightCyan", + "lightGoldenrodYellow", + "lightGray", + "lightGrey", + "lightGreen", + "lightPink", + "lightSalmon", + "lightSeaGreen", + "lightSkyBlue", + "lightSlateGray", + "lightSlateGrey", + "lightSteelBlue", + "lightYellow", + "ltBlue", + "ltCoral", + "ltCyan", + "ltGoldenrodYellow", + "ltGray", + "ltGrey", + "ltGreen", + "ltPink", + "ltSalmon", + "ltSeaGreen", + "ltSkyBlue", + "ltSlateGray", + "ltSlateGrey", + "ltSteelBlue", + "ltYellow", + "lime", + "limeGreen", + "linen", + "magenta", + "maroon", + "medAquamarine", + "medBlue", + "medOrchid", + "medPurple", + "medSeaGreen", + "medSlateBlue", + "medSpringGreen", + "medTurquoise", + "medVioletRed", + "mediumAquamarine", + "mediumBlue", + "mediumOrchid", + "mediumPurple", + "mediumSeaGreen", + "mediumSlateBlue", + "mediumSpringGreen", + "mediumTurquoise", + "mediumVioletRed", + "midnightBlue", + "mintCream", + "mistyRose", + "moccasin", + "navajoWhite", + "navy", + "oldLace", + "olive", + "oliveDrab", + "orange", + "orangeRed", + "orchid", + "paleGoldenrod", + "paleGreen", + "paleTurquoise", + "paleVioletRed", + "papayaWhip", + "peachPuff", + "peru", + "pink", + "plum", + "powderBlue", + "purple", + "red", + "rosyBrown", + "royalBlue", + "saddleBrown", + "salmon", + "sandyBrown", + "seaGreen", + "seaShell", + "sienna", + "silver", + "skyBlue", + "slateBlue", + "slateGray", + "slateGrey", + "snow", + "springGreen", + "steelBlue", + "tan", + "teal", + "thistle", + "tomato", + "turquoise", + "violet", + "wheat", + "white", + "whiteSmoke", + "yellow", + "yellowGreen", +] -PRESET_COLORS: Incomplete +PRESET_COLORS: list[_PresetColors] SCHEME_COLORS: Incomplete class Transform(Serialisable): ... @@ -70,32 +263,32 @@ class Transform(Serialisable): ... class SystemColor(Serialisable): tagname: str namespace: Incomplete - tint: Incomplete - shade: Incomplete + tint: NestedInteger[Literal[True]] + shade: NestedInteger[Literal[True]] comp: Typed[Transform, Literal[True]] inv: Typed[Transform, Literal[True]] gray: Typed[Transform, Literal[True]] - alpha: Incomplete - alphaOff: Incomplete - alphaMod: Incomplete - hue: Incomplete - hueOff: Incomplete - hueMod: Incomplete - sat: Incomplete - satOff: Incomplete - satMod: Incomplete - lum: Incomplete - lumOff: Incomplete - lumMod: Incomplete - red: Incomplete - redOff: Incomplete - redMod: Incomplete - green: Incomplete - greenOff: Incomplete - greenMod: Incomplete - blue: Incomplete - blueOff: Incomplete - blueMod: Incomplete + alpha: NestedInteger[Literal[True]] + alphaOff: NestedInteger[Literal[True]] + alphaMod: NestedInteger[Literal[True]] + hue: NestedInteger[Literal[True]] + hueOff: NestedInteger[Literal[True]] + hueMod: NestedInteger[Literal[True]] + sat: NestedInteger[Literal[True]] + satOff: NestedInteger[Literal[True]] + satMod: NestedInteger[Literal[True]] + lum: NestedInteger[Literal[True]] + lumOff: NestedInteger[Literal[True]] + lumMod: NestedInteger[Literal[True]] + red: NestedInteger[Literal[True]] + redOff: NestedInteger[Literal[True]] + redMod: NestedInteger[Literal[True]] + green: NestedInteger[Literal[True]] + greenOff: NestedInteger[Literal[True]] + greenMod: NestedInteger[Literal[True]] + blue: NestedInteger[Literal[True]] + blueOff: NestedInteger[Literal[True]] + blueMod: NestedInteger[Literal[True]] gamma: Typed[Transform, Literal[True]] invGamma: Typed[Transform, Literal[True]] val: Set[_SystemColorVal] @@ -105,32 +298,32 @@ class SystemColor(Serialisable): self, val: _SystemColorVal = "windowText", lastClr: Incomplete | None = None, - tint: Incomplete | None = None, - shade: Incomplete | None = None, + tint: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + shade: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, comp: Transform | None = None, inv: Transform | None = None, gray: Transform | None = None, - alpha: Incomplete | None = None, - alphaOff: Incomplete | None = None, - alphaMod: Incomplete | None = None, - hue: Incomplete | None = None, - hueOff: Incomplete | None = None, - hueMod: Incomplete | None = None, - sat: Incomplete | None = None, - satOff: Incomplete | None = None, - satMod: Incomplete | None = None, - lum: Incomplete | None = None, - lumOff: Incomplete | None = None, - lumMod: Incomplete | None = None, - red: Incomplete | None = None, - redOff: Incomplete | None = None, - redMod: Incomplete | None = None, - green: Incomplete | None = None, - greenOff: Incomplete | None = None, - greenMod: Incomplete | None = None, - blue: Incomplete | None = None, - blueOff: Incomplete | None = None, - blueMod: Incomplete | None = None, + alpha: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + alphaOff: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + alphaMod: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + hue: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + hueOff: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + hueMod: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + sat: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + satOff: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + satMod: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + lum: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + lumOff: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + lumMod: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + red: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + redOff: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + redMod: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + green: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + greenOff: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + greenMod: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + blue: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + blueOff: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + blueMod: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, gamma: Transform | None = None, invGamma: Transform | None = None, ) -> None: ... @@ -154,101 +347,101 @@ _RGBPercent: TypeAlias = RGBPercent class SchemeColor(Serialisable): tagname: str namespace: Incomplete - tint: Incomplete - shade: Incomplete - comp: Incomplete - inv: Incomplete - gray: Incomplete - alpha: Incomplete - alphaOff: Incomplete - alphaMod: Incomplete - hue: Incomplete - hueOff: Incomplete - hueMod: Incomplete - sat: Incomplete - satOff: Incomplete - satMod: Incomplete - lum: Incomplete - lumOff: Incomplete - lumMod: Incomplete - red: Incomplete - redOff: Incomplete - redMod: Incomplete - green: Incomplete - greenOff: Incomplete - greenMod: Incomplete - blue: Incomplete - blueOff: Incomplete - blueMod: Incomplete - gamma: Incomplete - invGamma: Incomplete + tint: NestedInteger[Literal[True]] + shade: NestedInteger[Literal[True]] + comp: EmptyTag[Literal[True]] + inv: NestedInteger[Literal[True]] + gray: NestedInteger[Literal[True]] + alpha: NestedInteger[Literal[True]] + alphaOff: NestedInteger[Literal[True]] + alphaMod: NestedInteger[Literal[True]] + hue: NestedInteger[Literal[True]] + hueOff: NestedInteger[Literal[True]] + hueMod: NestedInteger[Literal[True]] + sat: NestedInteger[Literal[True]] + satOff: NestedInteger[Literal[True]] + satMod: NestedInteger[Literal[True]] + lum: NestedInteger[Literal[True]] + lumOff: NestedInteger[Literal[True]] + lumMod: NestedInteger[Literal[True]] + red: NestedInteger[Literal[True]] + redOff: NestedInteger[Literal[True]] + redMod: NestedInteger[Literal[True]] + green: NestedInteger[Literal[True]] + greenOff: NestedInteger[Literal[True]] + greenMod: NestedInteger[Literal[True]] + blue: NestedInteger[Literal[True]] + blueOff: NestedInteger[Literal[True]] + blueMod: NestedInteger[Literal[True]] + gamma: EmptyTag[Literal[True]] + invGamma: EmptyTag[Literal[True]] val: Set[_SchemeColorVal] __elements__: ClassVar[tuple[str, ...]] @overload def __init__( self, - tint: Incomplete | None = None, - shade: Incomplete | None = None, - comp: Incomplete | None = None, - inv: Incomplete | None = None, - gray: Incomplete | None = None, - alpha: Incomplete | None = None, - alphaOff: Incomplete | None = None, - alphaMod: Incomplete | None = None, - hue: Incomplete | None = None, - hueOff: Incomplete | None = None, - hueMod: Incomplete | None = None, - sat: Incomplete | None = None, - satOff: Incomplete | None = None, - satMod: Incomplete | None = None, - lum: Incomplete | None = None, - lumOff: Incomplete | None = None, - lumMod: Incomplete | None = None, - red: Incomplete | None = None, - redOff: Incomplete | None = None, - redMod: Incomplete | None = None, - green: Incomplete | None = None, - greenOff: Incomplete | None = None, - greenMod: Incomplete | None = None, - blue: Incomplete | None = None, - blueOff: Incomplete | None = None, - blueMod: Incomplete | None = None, - gamma: Incomplete | None = None, - invGamma: Incomplete | None = None, + tint: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + shade: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + comp: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, + inv: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + gray: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + alpha: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + alphaOff: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + alphaMod: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + hue: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + hueOff: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + hueMod: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + sat: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + satOff: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + satMod: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + lum: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + lumOff: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + lumMod: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + red: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + redOff: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + redMod: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + green: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + greenOff: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + greenMod: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + blue: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + blueOff: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + blueMod: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + gamma: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, + invGamma: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, *, val: _SchemeColorVal, ) -> None: ... @overload def __init__( self, - tint: Incomplete | None, - shade: Incomplete | None, - comp: Incomplete | None, - inv: Incomplete | None, - gray: Incomplete | None, - alpha: Incomplete | None, - alphaOff: Incomplete | None, - alphaMod: Incomplete | None, - hue: Incomplete | None, - hueOff: Incomplete | None, - hueMod: Incomplete | None, - sat: Incomplete | None, - satOff: Incomplete | None, - satMod: Incomplete | None, - lum: Incomplete | None, - lumOff: Incomplete | None, - lumMod: Incomplete | None, - red: Incomplete | None, - redOff: Incomplete | None, - redMod: Incomplete | None, - green: Incomplete | None, - greenOff: Incomplete | None, - greenMod: Incomplete | None, - blue: Incomplete | None, - blueOff: Incomplete | None, - blueMod: Incomplete | None, - gamma: Incomplete | None, - invGamma: Incomplete | None, + tint: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None, + shade: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None, + comp: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None, + inv: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None, + gray: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None, + alpha: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None, + alphaOff: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None, + alphaMod: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None, + hue: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None, + hueOff: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None, + hueMod: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None, + sat: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None, + satOff: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None, + satMod: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None, + lum: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None, + lumOff: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None, + lumMod: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None, + red: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None, + redOff: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None, + redMod: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None, + green: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None, + greenOff: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None, + greenMod: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None, + blue: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None, + blueOff: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None, + blueMod: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None, + gamma: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None, + invGamma: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None, val: _SchemeColorVal, ) -> None: ... @@ -257,21 +450,21 @@ class ColorChoice(Serialisable): namespace: Incomplete scrgbClr: Typed[_RGBPercent, Literal[True]] RGBPercent: Alias - srgbClr: Incomplete + srgbClr: NestedValue[_RGBPercent, Literal[True]] RGB: Alias hslClr: Typed[HSLColor, Literal[True]] sysClr: Typed[SystemColor, Literal[True]] schemeClr: Typed[SystemColor, Literal[True]] - prstClr: Incomplete + prstClr: NestedNoneSet[_PresetColors] __elements__: ClassVar[tuple[str, ...]] def __init__( self, scrgbClr: _RGBPercent | None = None, - srgbClr: Incomplete | None = None, + srgbClr: _HasTagAndGet[_RGBPercent | None] | _RGBPercent | None = None, hslClr: HSLColor | None = None, sysClr: SystemColor | None = None, schemeClr: SystemColor | None = None, - prstClr: Incomplete | None = None, + prstClr: _NestedNoneSetParam[_PresetColors] = None, ) -> None: ... _COLOR_SET: tuple[_ColorSetType, ...] diff --git a/stubs/openpyxl/openpyxl/drawing/fill.pyi b/stubs/openpyxl/openpyxl/drawing/fill.pyi index 4ff6baf3d..3815afbd8 100644 --- a/stubs/openpyxl/openpyxl/drawing/fill.pyi +++ b/stubs/openpyxl/openpyxl/drawing/fill.pyi @@ -15,8 +15,9 @@ from openpyxl.descriptors.base import ( _ConvertibleToInt, ) from openpyxl.descriptors.excel import ExtensionList +from openpyxl.descriptors.nested import NestedNoneSet, NestedValue, _HasTagAndGet, _NestedNoneSetParam from openpyxl.descriptors.serialisable import Serialisable -from openpyxl.drawing.colors import ColorChoice, HSLColor, RGBPercent as _RGBPercent, SchemeColor, SystemColor +from openpyxl.drawing.colors import ColorChoice, HSLColor, RGBPercent as _RGBPercent, SchemeColor, SystemColor, _PresetColors from openpyxl.drawing.effect import ( AlphaBiLevelEffect, AlphaCeilingEffect, @@ -142,22 +143,22 @@ class GradientStop(Serialisable): pos: MinMax[float, Literal[True]] scrgbClr: Typed[_RGBPercent, Literal[True]] RGBPercent: Alias - srgbClr: Incomplete + srgbClr: NestedValue[_RGBPercent, Literal[True]] RGB: Alias hslClr: Typed[HSLColor, Literal[True]] sysClr: Typed[SystemColor, Literal[True]] schemeClr: Typed[SchemeColor, Literal[True]] - prstClr: Incomplete + prstClr: NestedNoneSet[_PresetColors] __elements__: ClassVar[tuple[str, ...]] def __init__( self, pos: _ConvertibleToFloat | None = None, scrgbClr: _RGBPercent | None = None, - srgbClr: Incomplete | None = None, + srgbClr: _HasTagAndGet[_RGBPercent | None] | _RGBPercent | None = None, hslClr: HSLColor | None = None, sysClr: SystemColor | None = None, schemeClr: SchemeColor | None = None, - prstClr: Incomplete | None = None, + prstClr: _NestedNoneSetParam[_PresetColors] = None, ) -> None: ... class LinearShadeProperties(Serialisable): @@ -200,21 +201,21 @@ class SolidColorFillProperties(Serialisable): tagname: str scrgbClr: Typed[_RGBPercent, Literal[True]] RGBPercent: Alias - srgbClr: Incomplete + srgbClr: NestedValue[_RGBPercent, Literal[True]] RGB: Alias hslClr: Typed[HSLColor, Literal[True]] sysClr: Typed[SystemColor, Literal[True]] schemeClr: Typed[SchemeColor, Literal[True]] - prstClr: Incomplete + prstClr: NestedNoneSet[_PresetColors] __elements__: ClassVar[tuple[str, ...]] def __init__( self, scrgbClr: _RGBPercent | None = None, - srgbClr: Incomplete | None = None, + srgbClr: _HasTagAndGet[_RGBPercent | None] | _RGBPercent | None = None, hslClr: HSLColor | None = None, sysClr: SystemColor | None = None, schemeClr: SchemeColor | None = None, - prstClr: Incomplete | None = None, + prstClr: _NestedNoneSetParam[_PresetColors] = None, ) -> None: ... class Blip(Serialisable): diff --git a/stubs/openpyxl/openpyxl/drawing/line.pyi b/stubs/openpyxl/openpyxl/drawing/line.pyi index af2e168af..df73f7b00 100644 --- a/stubs/openpyxl/openpyxl/drawing/line.pyi +++ b/stubs/openpyxl/openpyxl/drawing/line.pyi @@ -2,8 +2,18 @@ from _typeshed import Incomplete, Unused from typing import ClassVar from typing_extensions import Literal, TypeAlias -from openpyxl.descriptors.base import Alias, Integer, MinMax, NoneSet, Typed, _ConvertibleToFloat, _ConvertibleToInt +from openpyxl.descriptors.base import ( + Alias, + Integer, + MinMax, + NoneSet, + Typed, + _ConvertibleToBool, + _ConvertibleToFloat, + _ConvertibleToInt, +) from openpyxl.descriptors.excel import ExtensionList +from openpyxl.descriptors.nested import EmptyTag, NestedInteger, NestedNoneSet, _HasTagAndGet, _NestedNoneSetParam from openpyxl.descriptors.serialisable import Serialisable from openpyxl.drawing.fill import GradientFillProperties, PatternFillProperties @@ -12,6 +22,9 @@ _LineEndPropertiesWLen: TypeAlias = Literal["sm", "med", "lg"] _LinePropertiesCap: TypeAlias = Literal["rnd", "sq", "flat"] _LinePropertiesCmpd: TypeAlias = Literal["sng", "dbl", "thickThin", "thinThick", "tri"] _LinePropertiesAlgn: TypeAlias = Literal["ctr", "in"] +_LinePropertiesPrstDash: TypeAlias = Literal[ + "solid", "dot", "dash", "lgDash", "dashDot", "lgDashDot", "lgDashDotDot", "sysDash", "sysDot", "sysDashDot", "sysDashDotDot" +] class LineEndProperties(Serialisable): tagname: str @@ -47,16 +60,16 @@ class LineProperties(Serialisable): cap: NoneSet[_LinePropertiesCap] cmpd: NoneSet[_LinePropertiesCmpd] algn: NoneSet[_LinePropertiesAlgn] - noFill: Incomplete + noFill: EmptyTag[Literal[False]] solidFill: Incomplete gradFill: Typed[GradientFillProperties, Literal[True]] pattFill: Typed[PatternFillProperties, Literal[True]] - prstDash: Incomplete + prstDash: NestedNoneSet[_LinePropertiesPrstDash] dashStyle: Alias custDash: Typed[DashStop, Literal[True]] - round: Incomplete - bevel: Incomplete - miter: Incomplete + round: EmptyTag[Literal[False]] + bevel: EmptyTag[Literal[False]] + miter: NestedInteger[Literal[True]] headEnd: Typed[LineEndProperties, Literal[True]] tailEnd: Typed[LineEndProperties, Literal[True]] extLst: Typed[ExtensionList, Literal[True]] @@ -67,15 +80,15 @@ class LineProperties(Serialisable): cap: _LinePropertiesCap | Literal["none"] | None = None, cmpd: _LinePropertiesCmpd | Literal["none"] | None = None, algn: _LinePropertiesAlgn | Literal["none"] | None = None, - noFill: Incomplete | None = None, + noFill: _HasTagAndGet[_ConvertibleToBool] | _ConvertibleToBool = None, solidFill: Incomplete | None = None, gradFill: GradientFillProperties | None = None, pattFill: PatternFillProperties | None = None, - prstDash: Incomplete | None = None, + prstDash: _NestedNoneSetParam[_LinePropertiesPrstDash] = None, custDash: DashStop | None = None, - round: Incomplete | None = None, - bevel: Incomplete | None = None, - miter: Incomplete | None = None, + round: _HasTagAndGet[_ConvertibleToBool] | _ConvertibleToBool = None, + bevel: _HasTagAndGet[_ConvertibleToBool] | _ConvertibleToBool = None, + miter: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, headEnd: LineEndProperties | None = None, tailEnd: LineEndProperties | None = None, extLst: Unused = None, diff --git a/stubs/openpyxl/openpyxl/drawing/spreadsheet_drawing.pyi b/stubs/openpyxl/openpyxl/drawing/spreadsheet_drawing.pyi index 13b70b287..29229b282 100644 --- a/stubs/openpyxl/openpyxl/drawing/spreadsheet_drawing.pyi +++ b/stubs/openpyxl/openpyxl/drawing/spreadsheet_drawing.pyi @@ -2,7 +2,8 @@ from _typeshed import Incomplete from typing import ClassVar from typing_extensions import Literal, TypeAlias -from openpyxl.descriptors.base import Alias, Bool, NoneSet, Typed, _ConvertibleToBool +from openpyxl.descriptors.base import Alias, Bool, NoneSet, Typed, _ConvertibleToBool, _ConvertibleToInt +from openpyxl.descriptors.nested import NestedText from openpyxl.descriptors.serialisable import Serialisable from openpyxl.drawing.connector import Shape from openpyxl.drawing.graphic import GraphicFrame, GroupShape @@ -20,11 +21,13 @@ class AnchorClientData(Serialisable): class AnchorMarker(Serialisable): tagname: str - col: Incomplete - colOff: Incomplete - row: Incomplete - rowOff: Incomplete - def __init__(self, col: int = 0, colOff: int = 0, row: int = 0, rowOff: int = 0) -> None: ... + col: NestedText[int, Literal[False]] + colOff: NestedText[int, Literal[False]] + row: NestedText[int, Literal[False]] + rowOff: NestedText[int, Literal[False]] + def __init__( + self, col: _ConvertibleToInt = 0, colOff: _ConvertibleToInt = 0, row: _ConvertibleToInt = 0, rowOff: _ConvertibleToInt = 0 + ) -> None: ... class _AnchorBase(Serialisable): sp: Typed[Shape, Literal[True]] diff --git a/stubs/openpyxl/openpyxl/drawing/text.pyi b/stubs/openpyxl/openpyxl/drawing/text.pyi index 57eebdc0b..344835c4c 100644 --- a/stubs/openpyxl/openpyxl/drawing/text.pyi +++ b/stubs/openpyxl/openpyxl/drawing/text.pyi @@ -1,4 +1,4 @@ -from _typeshed import Incomplete +from _typeshed import Incomplete, Unused from typing import ClassVar from typing_extensions import Literal, TypeAlias @@ -16,9 +16,10 @@ from openpyxl.descriptors.base import ( _ConvertibleToInt, ) from openpyxl.descriptors.excel import Coordinate, ExtensionList +from openpyxl.descriptors.nested import EmptyTag, NestedBool, NestedInteger, NestedText, NestedValue, _HasTagAndGet from openpyxl.descriptors.serialisable import Serialisable from openpyxl.drawing.effect import Color, EffectContainer, EffectList -from openpyxl.drawing.fill import BlipFillProperties, GradientFillProperties, PatternFillProperties +from openpyxl.drawing.fill import Blip, BlipFillProperties, GradientFillProperties, PatternFillProperties from openpyxl.drawing.geometry import Scene3D from openpyxl.drawing.line import LineProperties @@ -217,20 +218,20 @@ class CharacterProperties(Serialisable): sym: Typed[Font, Literal[True]] hlinkClick: Typed[Hyperlink, Literal[True]] hlinkMouseOver: Typed[Hyperlink, Literal[True]] - rtl: Incomplete + rtl: NestedBool[Literal[True]] extLst: Typed[ExtensionList, Literal[True]] - noFill: Incomplete + noFill: EmptyTag[Literal[False]] solidFill: Incomplete gradFill: Typed[GradientFillProperties, Literal[True]] blipFill: Typed[BlipFillProperties, Literal[True]] pattFill: Typed[PatternFillProperties, Literal[True]] - grpFill: Incomplete + grpFill: EmptyTag[Literal[False]] effectLst: Typed[EffectList, Literal[True]] effectDag: Typed[EffectContainer, Literal[True]] - uLnTx: Incomplete + uLnTx: EmptyTag[Literal[False]] uLn: Typed[LineProperties, Literal[True]] - uFillTx: Incomplete - uFill: Incomplete + uFillTx: EmptyTag[Literal[False]] + uFill: EmptyTag[Literal[False]] __elements__: ClassVar[tuple[str, ...]] def __init__( self, @@ -261,20 +262,20 @@ class CharacterProperties(Serialisable): sym: Font | None = None, hlinkClick: Hyperlink | None = None, hlinkMouseOver: Hyperlink | None = None, - rtl: Incomplete | None = None, + rtl: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, extLst: ExtensionList | None = None, - noFill: Incomplete | None = None, + noFill: _HasTagAndGet[_ConvertibleToBool] | _ConvertibleToBool = None, solidFill: Incomplete | None = None, gradFill: GradientFillProperties | None = None, blipFill: BlipFillProperties | None = None, pattFill: PatternFillProperties | None = None, - grpFill: Incomplete | None = None, + grpFill: _HasTagAndGet[_ConvertibleToBool] | _ConvertibleToBool = None, effectLst: EffectList | None = None, effectDag: EffectContainer | None = None, - uLnTx: Incomplete | None = None, + uLnTx: _HasTagAndGet[_ConvertibleToBool] | _ConvertibleToBool = None, uLn: LineProperties | None = None, - uFillTx: Incomplete | None = None, - uFill: Incomplete | None = None, + uFillTx: _HasTagAndGet[_ConvertibleToBool] | _ConvertibleToBool = None, + uFill: _HasTagAndGet[_ConvertibleToBool] | _ConvertibleToBool = None, ) -> None: ... class TabStop(Serialisable): @@ -287,10 +288,14 @@ class TabStopList(Serialisable): def __init__(self, tab: Incomplete | None = None) -> None: ... class Spacing(Serialisable): - spcPct: Incomplete - spcPts: Incomplete + spcPct: NestedInteger[Literal[True]] + spcPts: NestedInteger[Literal[True]] __elements__: ClassVar[tuple[str, ...]] - def __init__(self, spcPct: Incomplete | None = None, spcPts: Incomplete | None = None) -> None: ... + def __init__( + self, + spcPct: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + spcPts: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + ) -> None: ... class AutonumberBullet(Serialisable): type: Set[_AutonumberBulletType] @@ -317,17 +322,17 @@ class ParagraphProperties(Serialisable): tabLst: Typed[TabStopList, Literal[True]] defRPr: Typed[CharacterProperties, Literal[True]] extLst: Typed[ExtensionList, Literal[True]] - buClrTx: Incomplete + buClrTx: EmptyTag[Literal[False]] buClr: Typed[Color, Literal[True]] - buSzTx: Incomplete - buSzPct: Incomplete - buSzPts: Incomplete - buFontTx: Incomplete + buSzTx: EmptyTag[Literal[False]] + buSzPct: NestedInteger[Literal[True]] + buSzPts: NestedInteger[Literal[True]] + buFontTx: EmptyTag[Literal[False]] buFont: Typed[Font, Literal[True]] - buNone: Incomplete - buAutoNum: Incomplete - buChar: Incomplete - buBlip: Incomplete + buNone: EmptyTag[Literal[False]] + buAutoNum: EmptyTag[Literal[False]] + buChar: NestedValue[str, Literal[True]] + buBlip: NestedValue[Blip, Literal[True]] __elements__: ClassVar[tuple[str, ...]] def __init__( self, @@ -348,17 +353,17 @@ class ParagraphProperties(Serialisable): tabLst: TabStopList | None = None, defRPr: CharacterProperties | None = None, extLst: ExtensionList | None = None, - buClrTx: Incomplete | None = None, + buClrTx: _HasTagAndGet[_ConvertibleToBool] | _ConvertibleToBool = None, buClr: Color | None = None, - buSzTx: Incomplete | None = None, - buSzPct: Incomplete | None = None, - buSzPts: Incomplete | None = None, - buFontTx: Incomplete | None = None, + buSzTx: _HasTagAndGet[_ConvertibleToBool] | _ConvertibleToBool = None, + buSzPct: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + buSzPts: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + buFontTx: _HasTagAndGet[_ConvertibleToBool] | _ConvertibleToBool = None, buFont: Font | None = None, - buNone: Incomplete | None = None, - buAutoNum: Incomplete | None = None, - buChar: Incomplete | None = None, - buBlip: Incomplete | None = None, + buNone: _HasTagAndGet[_ConvertibleToBool] | _ConvertibleToBool = None, + buAutoNum: _HasTagAndGet[_ConvertibleToBool] | _ConvertibleToBool = None, + buChar: object = None, + buBlip: object = None, ) -> None: ... class ListStyle(Serialisable): @@ -396,10 +401,10 @@ class RegularTextRun(Serialisable): namespace: Incomplete rPr: Typed[CharacterProperties, Literal[True]] properties: Alias - t: Incomplete + t: NestedText[str, Literal[False]] value: Alias __elements__: ClassVar[tuple[str, ...]] - def __init__(self, rPr: CharacterProperties | None = None, t: str = "") -> None: ... + def __init__(self, rPr: CharacterProperties | None = None, t: object = "") -> None: ... class LineBreak(Serialisable): tagname: str @@ -488,10 +493,10 @@ class RichTextProperties(Serialisable): prstTxWarp: Typed[PresetTextShape, Literal[True]] scene3d: Typed[Scene3D, Literal[True]] extLst: Typed[ExtensionList, Literal[True]] - noAutofit: Incomplete - normAutofit: Incomplete - spAutoFit: Incomplete - flatTx: Incomplete + noAutofit: EmptyTag[Literal[False]] + normAutofit: EmptyTag[Literal[False]] + spAutoFit: EmptyTag[Literal[False]] + flatTx: NestedInteger[Literal[True]] __elements__: ClassVar[tuple[str, ...]] def __init__( self, @@ -514,11 +519,11 @@ class RichTextProperties(Serialisable): forceAA: _ConvertibleToBool | None = None, upright: _ConvertibleToBool | None = None, compatLnSpc: _ConvertibleToBool | None = None, - prstTxWarp: Incomplete | None = None, - scene3d: Incomplete | None = None, - extLst: Incomplete | None = None, - noAutofit: Incomplete | None = None, - normAutofit: Incomplete | None = None, - spAutoFit: Incomplete | None = None, - flatTx: Incomplete | None = None, + prstTxWarp: PresetTextShape | None = None, + scene3d: Scene3D | None = None, + extLst: Unused = None, + noAutofit: _HasTagAndGet[_ConvertibleToBool] | _ConvertibleToBool = None, + normAutofit: _HasTagAndGet[_ConvertibleToBool] | _ConvertibleToBool = None, + spAutoFit: _HasTagAndGet[_ConvertibleToBool] | _ConvertibleToBool = None, + flatTx: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, ) -> None: ... diff --git a/stubs/openpyxl/openpyxl/packaging/core.pyi b/stubs/openpyxl/openpyxl/packaging/core.pyi index 96e68ca37..d1277d22b 100644 --- a/stubs/openpyxl/openpyxl/packaging/core.pyi +++ b/stubs/openpyxl/openpyxl/packaging/core.pyi @@ -1,5 +1,6 @@ from _typeshed import Incomplete from typing import ClassVar +from typing_extensions import Literal from openpyxl.descriptors import DateTime from openpyxl.descriptors.base import Alias @@ -7,7 +8,7 @@ from openpyxl.descriptors.nested import NestedText from openpyxl.descriptors.serialisable import Serialisable # Does not reimplement the relevant methods, so runtime also has incompatible supertypes -class NestedDateTime(DateTime[Incomplete], NestedText): # type: ignore[misc] +class NestedDateTime(DateTime[Incomplete], NestedText[Incomplete, Incomplete]): # type: ignore[misc] expected_type: type[Incomplete] def to_tree( self, tagname: Incomplete | None = None, value: Incomplete | None = None, namespace: Incomplete | None = None @@ -21,38 +22,38 @@ class QualifiedDateTime(NestedDateTime): class DocumentProperties(Serialisable): tagname: str namespace: Incomplete - category: Incomplete - contentStatus: Incomplete - keywords: Incomplete - lastModifiedBy: Incomplete + category: NestedText[str, Literal[True]] + contentStatus: NestedText[str, Literal[True]] + keywords: NestedText[str, Literal[True]] + lastModifiedBy: NestedText[str, Literal[True]] lastPrinted: Incomplete - revision: Incomplete - version: Incomplete + revision: NestedText[str, Literal[True]] + version: NestedText[str, Literal[True]] last_modified_by: Alias - subject: Incomplete - title: Incomplete - creator: Incomplete - description: Incomplete - identifier: Incomplete - language: Incomplete + subject: NestedText[str, Literal[True]] + title: NestedText[str, Literal[True]] + creator: NestedText[str, Literal[True]] + description: NestedText[str, Literal[True]] + identifier: NestedText[str, Literal[True]] + language: NestedText[str, Literal[True]] created: Incomplete modified: Incomplete __elements__: ClassVar[tuple[str, ...]] def __init__( self, - category: Incomplete | None = None, - contentStatus: Incomplete | None = None, - keywords: Incomplete | None = None, - lastModifiedBy: Incomplete | None = None, + category: object = None, + contentStatus: object = None, + keywords: object = None, + lastModifiedBy: object = None, lastPrinted: Incomplete | None = None, - revision: Incomplete | None = None, - version: Incomplete | None = None, + revision: object = None, + version: object = None, created=None, - creator: str = "openpyxl", - description: Incomplete | None = None, - identifier: Incomplete | None = None, - language: Incomplete | None = None, + creator: object = "openpyxl", + description: object = None, + identifier: object = None, + language: object = None, modified=None, - subject: Incomplete | None = None, - title: Incomplete | None = None, + subject: object = None, + title: object = None, ) -> None: ... diff --git a/stubs/openpyxl/openpyxl/packaging/custom.pyi b/stubs/openpyxl/openpyxl/packaging/custom.pyi index 188498ea0..ba279e6e1 100644 --- a/stubs/openpyxl/openpyxl/packaging/custom.pyi +++ b/stubs/openpyxl/openpyxl/packaging/custom.pyi @@ -20,7 +20,7 @@ from openpyxl.descriptors.nested import NestedText _T = TypeVar("_T") # Does not reimplement anything, so runtime also has incompatible supertypes -class NestedBoolText(Bool[Incomplete], NestedText): ... # type: ignore[misc] +class NestedBoolText(Bool[Incomplete], NestedText[Incomplete, Incomplete]): ... # type: ignore[misc] class _TypedProperty(Strict, Generic[_T]): name: String[Literal[False]] diff --git a/stubs/openpyxl/openpyxl/packaging/extended.pyi b/stubs/openpyxl/openpyxl/packaging/extended.pyi index c50f9fe3f..2d0721c54 100644 --- a/stubs/openpyxl/openpyxl/packaging/extended.pyi +++ b/stubs/openpyxl/openpyxl/packaging/extended.pyi @@ -1,8 +1,9 @@ -from _typeshed import Incomplete, Unused +from _typeshed import Unused from typing import ClassVar from typing_extensions import Literal -from openpyxl.descriptors.base import Typed +from openpyxl.descriptors.base import Typed, _ConvertibleToInt +from openpyxl.descriptors.nested import NestedText from openpyxl.descriptors.serialisable import Serialisable def get_version(): ... @@ -21,62 +22,62 @@ class VectorVariant(Serialisable): class ExtendedProperties(Serialisable): tagname: str - Template: Incomplete - Manager: Incomplete - Company: Incomplete - Pages: Incomplete - Words: Incomplete - Characters: Incomplete - PresentationFormat: Incomplete - Lines: Incomplete - Paragraphs: Incomplete - Slides: Incomplete - Notes: Incomplete - TotalTime: Incomplete - HiddenSlides: Incomplete - MMClips: Incomplete - ScaleCrop: Incomplete + Template: NestedText[str, Literal[True]] + Manager: NestedText[str, Literal[True]] + Company: NestedText[str, Literal[True]] + Pages: NestedText[int, Literal[True]] + Words: NestedText[int, Literal[True]] + Characters: NestedText[int, Literal[True]] + PresentationFormat: NestedText[str, Literal[True]] + Lines: NestedText[int, Literal[True]] + Paragraphs: NestedText[int, Literal[True]] + Slides: NestedText[int, Literal[True]] + Notes: NestedText[int, Literal[True]] + TotalTime: NestedText[int, Literal[True]] + HiddenSlides: NestedText[int, Literal[True]] + MMClips: NestedText[int, Literal[True]] + ScaleCrop: NestedText[str, Literal[True]] HeadingPairs: Typed[VectorVariant, Literal[True]] TitlesOfParts: Typed[VectorLpstr, Literal[True]] - LinksUpToDate: Incomplete - CharactersWithSpaces: Incomplete - SharedDoc: Incomplete - HyperlinkBase: Incomplete + LinksUpToDate: NestedText[str, Literal[True]] + CharactersWithSpaces: NestedText[int, Literal[True]] + SharedDoc: NestedText[str, Literal[True]] + HyperlinkBase: NestedText[str, Literal[True]] HLinks: Typed[VectorVariant, Literal[True]] - HyperlinksChanged: Incomplete + HyperlinksChanged: NestedText[str, Literal[True]] DigSig: Typed[DigSigBlob, Literal[True]] - Application: Incomplete - AppVersion: Incomplete - DocSecurity: Incomplete + Application: NestedText[str, Literal[True]] + AppVersion: NestedText[str, Literal[True]] + DocSecurity: NestedText[int, Literal[True]] __elements__: ClassVar[tuple[str, ...]] def __init__( self, - Template: Incomplete | None = None, - Manager: Incomplete | None = None, - Company: Incomplete | None = None, - Pages: Incomplete | None = None, - Words: Incomplete | None = None, - Characters: Incomplete | None = None, - PresentationFormat: Incomplete | None = None, - Lines: Incomplete | None = None, - Paragraphs: Incomplete | None = None, - Slides: Incomplete | None = None, - Notes: Incomplete | None = None, - TotalTime: Incomplete | None = None, - HiddenSlides: Incomplete | None = None, - MMClips: Incomplete | None = None, - ScaleCrop: Incomplete | None = None, + Template: object = None, + Manager: object = None, + Company: object = None, + Pages: _ConvertibleToInt | None = None, + Words: _ConvertibleToInt | None = None, + Characters: _ConvertibleToInt | None = None, + PresentationFormat: object = None, + Lines: _ConvertibleToInt | None = None, + Paragraphs: _ConvertibleToInt | None = None, + Slides: _ConvertibleToInt | None = None, + Notes: _ConvertibleToInt | None = None, + TotalTime: _ConvertibleToInt | None = None, + HiddenSlides: _ConvertibleToInt | None = None, + MMClips: _ConvertibleToInt | None = None, + ScaleCrop: object = None, HeadingPairs: Unused = None, TitlesOfParts: Unused = None, - LinksUpToDate: Incomplete | None = None, - CharactersWithSpaces: Incomplete | None = None, - SharedDoc: Incomplete | None = None, - HyperlinkBase: Incomplete | None = None, + LinksUpToDate: object = None, + CharactersWithSpaces: _ConvertibleToInt | None = None, + SharedDoc: object = None, + HyperlinkBase: object = None, HLinks: Unused = None, - HyperlinksChanged: Incomplete | None = None, + HyperlinksChanged: object = None, DigSig: Unused = None, - Application: str = "Microsoft Excel", - AppVersion: Incomplete | None = None, - DocSecurity: Incomplete | None = None, + Application: object = "Microsoft Excel", + AppVersion: object = None, + DocSecurity: _ConvertibleToInt | None = None, ) -> None: ... def to_tree(self): ... diff --git a/stubs/openpyxl/openpyxl/packaging/workbook.pyi b/stubs/openpyxl/openpyxl/packaging/workbook.pyi index 4875deb6b..90f00471a 100644 --- a/stubs/openpyxl/openpyxl/packaging/workbook.pyi +++ b/stubs/openpyxl/openpyxl/packaging/workbook.pyi @@ -4,6 +4,7 @@ from typing_extensions import Literal, TypeAlias from openpyxl.descriptors.base import Alias, Bool, Integer, NoneSet, String, Typed, _ConvertibleToBool, _ConvertibleToInt from openpyxl.descriptors.excel import ExtensionList +from openpyxl.descriptors.nested import NestedString from openpyxl.descriptors.serialisable import Serialisable from openpyxl.workbook.defined_name import DefinedNameList from openpyxl.workbook.function_group import FunctionGroupList @@ -63,7 +64,7 @@ class WorkbookPackage(Serialisable): externalReferences: Incomplete definedNames: Typed[DefinedNameList, Literal[True]] calcPr: Typed[CalcProperties, Literal[True]] - oleSize: Incomplete + oleSize: NestedString[Literal[True]] customWorkbookViews: Incomplete pivotCaches: Incomplete smartTagPr: Typed[SmartTagProperties, Literal[True]] @@ -72,7 +73,7 @@ class WorkbookPackage(Serialisable): fileRecoveryPr: Typed[FileRecoveryProperties, Literal[True]] webPublishObjects: Typed[WebPublishObjectList, Literal[True]] extLst: Typed[ExtensionList, Literal[True]] - Ignorable: Incomplete + Ignorable: NestedString[Literal[True]] __elements__: ClassVar[tuple[str, ...]] def __init__( self, @@ -87,7 +88,7 @@ class WorkbookPackage(Serialisable): externalReferences=(), definedNames: DefinedNameList | None = None, calcPr: CalcProperties | None = None, - oleSize: Incomplete | None = None, + oleSize: object = None, customWorkbookViews=(), pivotCaches=(), smartTagPr: SmartTagProperties | None = None, diff --git a/stubs/openpyxl/openpyxl/pivot/cache.pyi b/stubs/openpyxl/openpyxl/pivot/cache.pyi index 2a456dc95..864b43e7f 100644 --- a/stubs/openpyxl/openpyxl/pivot/cache.pyi +++ b/stubs/openpyxl/openpyxl/pivot/cache.pyi @@ -16,6 +16,7 @@ from openpyxl.descriptors.base import ( _ConvertibleToInt, ) from openpyxl.descriptors.excel import ExtensionList +from openpyxl.descriptors.nested import NestedInteger, _HasTagAndGet from openpyxl.descriptors.serialisable import Serialisable from openpyxl.pivot.fields import Error, Missing, Number, Text, TupleList from openpyxl.pivot.table import PivotArea @@ -386,9 +387,11 @@ class GroupItems(Serialisable): class DiscretePr(Serialisable): tagname: str count: Integer[Literal[False]] - x: Incomplete + x: NestedInteger[Literal[True]] __elements__: ClassVar[tuple[str, ...]] - def __init__(self, count: _ConvertibleToInt, x: Incomplete | None = None) -> None: ... + def __init__( + self, count: _ConvertibleToInt, x: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None + ) -> None: ... class RangePr(Serialisable): tagname: str @@ -476,7 +479,7 @@ class CacheField(Serialisable): tagname: str sharedItems: Typed[SharedItems, Literal[True]] fieldGroup: Typed[FieldGroup, Literal[True]] - mpMap: Incomplete + mpMap: NestedInteger[Literal[True]] extLst: Typed[ExtensionList, Literal[True]] name: String[Literal[False]] caption: String[Literal[True]] @@ -497,7 +500,7 @@ class CacheField(Serialisable): self, sharedItems: SharedItems | None = None, fieldGroup: FieldGroup | None = None, - mpMap: Incomplete | None = None, + mpMap: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, extLst: ExtensionList | None = None, *, name: str, diff --git a/stubs/openpyxl/openpyxl/styles/fonts.pyi b/stubs/openpyxl/openpyxl/styles/fonts.pyi index 88ad1e98e..c61cb4cbb 100644 --- a/stubs/openpyxl/openpyxl/styles/fonts.pyi +++ b/stubs/openpyxl/openpyxl/styles/fonts.pyi @@ -1,58 +1,73 @@ from _typeshed import Incomplete from typing import ClassVar +from typing_extensions import Literal, TypeAlias -from openpyxl.descriptors.base import Alias +from openpyxl.descriptors.base import Alias, _ConvertibleToBool, _ConvertibleToFloat, _ConvertibleToInt +from openpyxl.descriptors.nested import ( + NestedBool, + NestedFloat, + NestedInteger, + NestedMinMax, + NestedNoneSet, + NestedString, + _HasTagAndGet, + _NestedNoneSetParam, +) from openpyxl.descriptors.serialisable import Serialisable +_FontU: TypeAlias = Literal["single", "double", "singleAccounting", "doubleAccounting"] +_FontVertAlign: TypeAlias = Literal["superscript", "subscript", "baseline"] +_FontScheme: TypeAlias = Literal["major", "minor"] + class Font(Serialisable): UNDERLINE_DOUBLE: str UNDERLINE_DOUBLE_ACCOUNTING: str UNDERLINE_SINGLE: str UNDERLINE_SINGLE_ACCOUNTING: str - name: Incomplete - charset: Incomplete - family: Incomplete - sz: Incomplete + name: NestedString[Literal[True]] + charset: NestedInteger[Literal[True]] + family: NestedMinMax[float, Literal[True]] + sz: NestedFloat[Literal[True]] size: Alias - b: Incomplete + b: NestedBool[Literal[False]] bold: Alias - i: Incomplete + i: NestedBool[Literal[False]] italic: Alias - strike: Incomplete + strike: NestedBool[Literal[True]] strikethrough: Alias - outline: Incomplete - shadow: Incomplete - condense: Incomplete - extend: Incomplete - u: Incomplete + outline: NestedBool[Literal[True]] + shadow: NestedBool[Literal[True]] + condense: NestedBool[Literal[True]] + extend: NestedBool[Literal[True]] + u: NestedNoneSet[_FontU] underline: Alias - vertAlign: Incomplete + vertAlign: NestedNoneSet[_FontVertAlign] color: Incomplete - scheme: Incomplete + scheme: NestedNoneSet[_FontScheme] tagname: str __elements__: ClassVar[tuple[str, ...]] def __init__( self, - name: Incomplete | None = None, - sz: Incomplete | None = None, - b: Incomplete | None = None, - i: Incomplete | None = None, - charset: Incomplete | None = None, - u: Incomplete | None = None, - strike: Incomplete | None = None, + name: object = None, + sz: _HasTagAndGet[_ConvertibleToFloat | None] | _ConvertibleToFloat | None = None, + b: _HasTagAndGet[_ConvertibleToBool] | _ConvertibleToBool = None, + i: _HasTagAndGet[_ConvertibleToBool] | _ConvertibleToBool = None, + charset: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None, + u: _NestedNoneSetParam[_FontU] = None, + strike: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, color: Incomplete | None = None, - scheme: Incomplete | None = None, - family: Incomplete | None = None, - size: Incomplete | None = None, - bold: Incomplete | None = None, - italic: Incomplete | None = None, - strikethrough: Incomplete | None = None, - underline: Incomplete | None = None, - vertAlign: Incomplete | None = None, - outline: Incomplete | None = None, - shadow: Incomplete | None = None, - condense: Incomplete | None = None, - extend: Incomplete | None = None, + scheme: _NestedNoneSetParam[_FontScheme] = None, + family: _HasTagAndGet[_ConvertibleToFloat | None] | _ConvertibleToFloat | None = None, + size: _HasTagAndGet[_ConvertibleToFloat] | _ConvertibleToFloat | None = None, + bold: _HasTagAndGet[_ConvertibleToBool] | _ConvertibleToBool | None = None, + italic: _HasTagAndGet[_ConvertibleToBool] | _ConvertibleToBool | None = None, + strikethrough: _HasTagAndGet[_ConvertibleToBool] | _ConvertibleToBool | None = None, + underline: _NestedNoneSetParam[_FontU] = None, + vertAlign: _NestedNoneSetParam[_FontVertAlign] = None, + outline: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, + shadow: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, + condense: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, + extend: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None, ) -> None: ... @classmethod def from_tree(cls, node): ... diff --git a/stubs/openpyxl/openpyxl/workbook/external_link/external.pyi b/stubs/openpyxl/openpyxl/workbook/external_link/external.pyi index 947ebe992..b217df769 100644 --- a/stubs/openpyxl/openpyxl/workbook/external_link/external.pyi +++ b/stubs/openpyxl/openpyxl/workbook/external_link/external.pyi @@ -3,6 +3,7 @@ from typing import ClassVar from typing_extensions import Literal, TypeAlias from openpyxl.descriptors.base import Bool, Integer, NoneSet, String, Typed, _ConvertibleToBool, _ConvertibleToInt +from openpyxl.descriptors.nested import NestedText from openpyxl.descriptors.serialisable import Serialisable from openpyxl.packaging.relationship import Relationship @@ -12,13 +13,9 @@ class ExternalCell(Serialisable): r: String[Literal[False]] t: NoneSet[_ExternalCellType] vm: Integer[Literal[True]] - v: Incomplete + v: NestedText[str, Literal[True]] def __init__( - self, - r: str, - t: _ExternalCellType | Literal["none"] | None = None, - vm: _ConvertibleToInt | None = None, - v: Incomplete | None = None, + self, r: str, t: _ExternalCellType | Literal["none"] | None = None, vm: _ConvertibleToInt | None = None, v: object = None ) -> None: ... class ExternalRow(Serialisable): diff --git a/stubs/openpyxl/openpyxl/worksheet/datavalidation.pyi b/stubs/openpyxl/openpyxl/worksheet/datavalidation.pyi index fca6efb4f..b5c567952 100644 --- a/stubs/openpyxl/openpyxl/worksheet/datavalidation.pyi +++ b/stubs/openpyxl/openpyxl/worksheet/datavalidation.pyi @@ -13,6 +13,7 @@ from openpyxl.descriptors.base import ( _ConvertibleToInt, _ConvertibleToMultiCellRange, ) +from openpyxl.descriptors.nested import NestedText from openpyxl.descriptors.serialisable import Serialisable from openpyxl.worksheet.cell_range import MultiCellRange @@ -53,8 +54,8 @@ class DataValidation(Serialisable): error: String[Literal[True]] promptTitle: String[Literal[True]] prompt: String[Literal[True]] - formula1: Incomplete - formula2: Incomplete + formula1: NestedText[str, Literal[True]] + formula2: NestedText[str, Literal[True]] type: NoneSet[_DataValidationType] errorStyle: NoneSet[_DataValidationErrorStyle] imeMode: NoneSet[_DataValidationImeMode] @@ -63,8 +64,8 @@ class DataValidation(Serialisable): def __init__( self, type: _DataValidationType | Literal["none"] | None = None, - formula1: Incomplete | None = None, - formula2: Incomplete | None = None, + formula1: object = None, + formula2: object = None, showErrorMessage: _ConvertibleToBool | None = False, showInputMessage: _ConvertibleToBool | None = False, showDropDown: _ConvertibleToBool | None = False,