mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-05-24 09:18:40 +08:00
[openpyxl] Complete base descriptors (#10001)
This commit is contained in:
@@ -7,3 +7,171 @@ openpyxl.utils.dataframe
|
||||
# Element can be imported from lxml or xml.etree, so the attributes can
|
||||
# differ at runtime.
|
||||
openpyxl.xml.functions.Element.*
|
||||
|
||||
# Fake getters
|
||||
openpyxl\.descriptors\..*\.__get__
|
||||
|
||||
# Stubtest sees <class T> and type[T] as different: https://github.com/python/mypy/issues/13316
|
||||
openpyxl.chart.descriptors.NumberFormatDescriptor.expected_type
|
||||
openpyxl.chart.title.TitleDescriptor.expected_type
|
||||
openpyxl.drawing.colors.ColorChoiceDescriptor.expected_type
|
||||
openpyxl.styles.colors.ColorDescriptor.expected_type
|
||||
|
||||
# Stubtest doesn't like generics here
|
||||
openpyxl\.descriptors\.(base\.)?Bool\.allow_none
|
||||
openpyxl\.descriptors\.(base\.)?DateTime\.allow_none
|
||||
openpyxl\.descriptors\.(base\.)?Float\.allow_none
|
||||
openpyxl\.descriptors\.(base\.)?Integer\.allow_none
|
||||
openpyxl\.descriptors\.(base\.)?MatchPattern\.allow_none
|
||||
openpyxl\.descriptors\.(base\.)?Max\.allow_none
|
||||
openpyxl\.descriptors\.(base\.)?Min\.allow_none
|
||||
openpyxl\.descriptors\.(base\.)?MinMax\.allow_none
|
||||
openpyxl\.descriptors\.(base\.)?String\.allow_none
|
||||
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.chartspace.ChartSpace.__init__
|
||||
openpyxl.chart.chartspace.ExternalData.__init__
|
||||
openpyxl.chart.data_source.NumFmt.__init__
|
||||
openpyxl.chart.data_source.NumVal.__init__
|
||||
openpyxl.chartsheet.custom.CustomChartsheetView.__init__
|
||||
openpyxl.chartsheet.publish.WebPublishItem.__init__
|
||||
openpyxl.comments.comment_sheet.CommentSheet.__init__
|
||||
openpyxl.comments.comment_sheet.Properties.__init__
|
||||
openpyxl.descriptors.excel.Extension.__init__
|
||||
openpyxl.drawing.colors.HSLColor.__init__
|
||||
openpyxl.drawing.colors.RGBPercent.__init__
|
||||
openpyxl.drawing.colors.SchemeColor.__init__
|
||||
openpyxl.drawing.connector.Connection.__init__
|
||||
openpyxl.drawing.connector.ConnectorNonVisual.__init__
|
||||
openpyxl.drawing.connector.ConnectorShape.__init__
|
||||
openpyxl.drawing.connector.Shape.__init__
|
||||
openpyxl.drawing.connector.ShapeMeta.__init__
|
||||
openpyxl.drawing.effect.AlphaBiLevelEffect.__init__
|
||||
openpyxl.drawing.effect.AlphaModulateEffect.__init__
|
||||
openpyxl.drawing.effect.AlphaModulateFixedEffect.__init__
|
||||
openpyxl.drawing.effect.AlphaReplaceEffect.__init__
|
||||
openpyxl.drawing.effect.BiLevelEffect.__init__
|
||||
openpyxl.drawing.effect.BlurEffect.__init__
|
||||
openpyxl.drawing.effect.ColorChangeEffect.__init__
|
||||
openpyxl.drawing.effect.EffectContainer.__init__
|
||||
openpyxl.drawing.effect.FillOverlayEffect.__init__
|
||||
openpyxl.drawing.effect.GlowEffect.__init__
|
||||
openpyxl.drawing.effect.HSLEffect.__init__
|
||||
openpyxl.drawing.effect.InnerShadowEffect.__init__
|
||||
openpyxl.drawing.effect.OuterShadow.__init__
|
||||
openpyxl.drawing.effect.PresetShadowEffect.__init__
|
||||
openpyxl.drawing.effect.ReflectionEffect.__init__
|
||||
openpyxl.drawing.effect.SoftEdgesEffect.__init__
|
||||
openpyxl.drawing.fill.LinearShadeProperties.__init__
|
||||
openpyxl.drawing.fill.PathShadeProperties.__init__
|
||||
openpyxl.drawing.fill.TileInfoProperties.__init__
|
||||
openpyxl.drawing.geometry.Backdrop.__init__
|
||||
openpyxl.drawing.geometry.Bevel.__init__
|
||||
openpyxl.drawing.geometry.Camera.__init__
|
||||
openpyxl.drawing.geometry.ConnectionSite.__init__
|
||||
openpyxl.drawing.geometry.CustomGeometry2D.__init__
|
||||
openpyxl.drawing.geometry.GeomGuide.__init__
|
||||
openpyxl.drawing.geometry.LightRig.__init__
|
||||
openpyxl.drawing.geometry.Path2D.__init__
|
||||
openpyxl.drawing.geometry.Point3D.__init__
|
||||
openpyxl.drawing.geometry.PositiveSize2D.__init__
|
||||
openpyxl.drawing.geometry.PresetGeometry2D.__init__
|
||||
openpyxl.drawing.geometry.Scene3D.__init__
|
||||
openpyxl.drawing.geometry.ShapeStyle.__init__
|
||||
openpyxl.drawing.geometry.SphereCoords.__init__
|
||||
openpyxl.drawing.geometry.StyleMatrixReference.__init__
|
||||
openpyxl.drawing.geometry.Vector3D.__init__
|
||||
openpyxl.drawing.graphic.GroupShape.__init__
|
||||
openpyxl.drawing.properties.NonVisualDrawingProps.__init__
|
||||
openpyxl.drawing.properties.NonVisualGroupShape.__init__
|
||||
openpyxl.drawing.text.AutonumberBullet.__init__
|
||||
openpyxl.drawing.text.Font.__init__
|
||||
openpyxl.drawing.text.GeomGuide.__init__
|
||||
openpyxl.drawing.text.PresetTextShape.__init__
|
||||
openpyxl.drawing.text.TextField.__init__
|
||||
openpyxl.drawing.text.TextNormalAutofit.__init__
|
||||
openpyxl.packaging.relationship.Relationship.__init__
|
||||
openpyxl.packaging.workbook.ChildSheet.__init__
|
||||
openpyxl.packaging.workbook.PivotCache.__init__
|
||||
openpyxl.pivot.cache.CacheDefinition.__init__
|
||||
openpyxl.pivot.cache.CacheField.__init__
|
||||
openpyxl.pivot.cache.CacheHierarchy.__init__
|
||||
openpyxl.pivot.cache.CacheSource.__init__
|
||||
openpyxl.pivot.cache.CalculatedItem.__init__
|
||||
openpyxl.pivot.cache.CalculatedMember.__init__
|
||||
openpyxl.pivot.cache.DiscretePr.__init__
|
||||
openpyxl.pivot.cache.FieldsUsage.__init__
|
||||
openpyxl.pivot.cache.FieldUsage.__init__
|
||||
openpyxl.pivot.cache.GroupLevel.__init__
|
||||
openpyxl.pivot.cache.GroupLevels.__init__
|
||||
openpyxl.pivot.cache.GroupMember.__init__
|
||||
openpyxl.pivot.cache.GroupMembers.__init__
|
||||
openpyxl.pivot.cache.Groups.__init__
|
||||
openpyxl.pivot.cache.LevelGroup.__init__
|
||||
openpyxl.pivot.cache.MeasureGroup.__init__
|
||||
openpyxl.pivot.cache.OLAPSet.__init__
|
||||
openpyxl.pivot.cache.OLAPSets.__init__
|
||||
openpyxl.pivot.cache.PageItem.__init__
|
||||
openpyxl.pivot.cache.PCDKPI.__init__
|
||||
openpyxl.pivot.cache.PCDSDTCEntries.__init__
|
||||
openpyxl.pivot.cache.PivotDimension.__init__
|
||||
openpyxl.pivot.cache.Query.__init__
|
||||
openpyxl.pivot.cache.QueryCache.__init__
|
||||
openpyxl.pivot.cache.RangeSet.__init__
|
||||
openpyxl.pivot.fields.Error.__init__
|
||||
openpyxl.pivot.fields.Number.__init__
|
||||
openpyxl.pivot.fields.Tuple.__init__
|
||||
openpyxl.pivot.fields.TupleList.__init__
|
||||
openpyxl.pivot.table.AutoSortScope.__init__
|
||||
openpyxl.pivot.table.ChartFormat.__init__
|
||||
openpyxl.pivot.table.ConditionalFormat.__init__
|
||||
openpyxl.pivot.table.DataField.__init__
|
||||
openpyxl.pivot.table.Format.__init__
|
||||
openpyxl.pivot.table.HierarchyUsage.__init__
|
||||
openpyxl.pivot.table.Location.__init__
|
||||
openpyxl.pivot.table.MemberProperty.__init__
|
||||
openpyxl.pivot.table.PageField.__init__
|
||||
openpyxl.pivot.table.PivotFilter.__init__
|
||||
openpyxl.pivot.table.PivotFilters.__init__
|
||||
openpyxl.pivot.table.RowColField.__init__
|
||||
openpyxl.pivot.table.TableDefinition.__init__
|
||||
openpyxl.styles.named_styles._NamedCellStyle.__init__
|
||||
openpyxl.styles.numbers.NumberFormat.__init__
|
||||
openpyxl.styles.table.TableStyle.__init__
|
||||
openpyxl.styles.table.TableStyleElement.__init__
|
||||
openpyxl.workbook.defined_name.DefinedName.__init__
|
||||
openpyxl.workbook.external_link.external.ExternalCell.__init__
|
||||
openpyxl.workbook.external_link.external.ExternalDefinedName.__init__
|
||||
openpyxl.workbook.external_link.external.ExternalRow.__init__
|
||||
openpyxl.workbook.external_link.external.ExternalSheetData.__init__
|
||||
openpyxl.workbook.function_group.FunctionGroup.__init__
|
||||
openpyxl.workbook.views.CustomWorkbookView.__init__
|
||||
openpyxl.workbook.web.WebPublishObject.__init__
|
||||
openpyxl.worksheet.cell_watch.CellWatch.__init__
|
||||
openpyxl.worksheet.controls.Control.__init__
|
||||
openpyxl.worksheet.controls.ControlProperty.__init__
|
||||
openpyxl.worksheet.custom.CustomProperty.__init__
|
||||
openpyxl.worksheet.dimensions.RowDimension.__init__
|
||||
openpyxl.worksheet.dimensions.SheetDimension.__init__
|
||||
openpyxl.worksheet.filters.DateGroupItem.__init__
|
||||
openpyxl.worksheet.filters.DynamicFilter.__init__
|
||||
openpyxl.worksheet.filters.FilterColumn.__init__
|
||||
openpyxl.worksheet.filters.IconFilter.__init__
|
||||
openpyxl.worksheet.filters.Top10.__init__
|
||||
openpyxl.worksheet.hyperlink.Hyperlink.__init__
|
||||
openpyxl.worksheet.ole.ObjectAnchor.__init__
|
||||
openpyxl.worksheet.ole.ObjectPr.__init__
|
||||
openpyxl.worksheet.ole.OleObject.__init__
|
||||
openpyxl.worksheet.print_settings.RowRange.__init__
|
||||
openpyxl.worksheet.scenario.InputCells.__init__
|
||||
openpyxl.worksheet.scenario.Scenario.__init__
|
||||
openpyxl.worksheet.smart_tag.CellSmartTag.__init__
|
||||
openpyxl.worksheet.smart_tag.CellSmartTagPr.__init__
|
||||
openpyxl.worksheet.smart_tag.CellSmartTags.__init__
|
||||
openpyxl.worksheet.table.TableColumn.__init__
|
||||
openpyxl.worksheet.table.XMLColumnProps.__init__
|
||||
|
||||
@@ -0,0 +1,392 @@
|
||||
# Needed until mypy issues are solved
|
||||
# pyright: reportUnnecessaryTypeIgnoreComment=false
|
||||
from __future__ import annotations
|
||||
|
||||
from _typeshed import ReadableBuffer
|
||||
from datetime import date, datetime, time
|
||||
from typing import Any, List, Tuple, Union
|
||||
from typing_extensions import Literal, assert_type
|
||||
|
||||
from openpyxl.descriptors import Strict
|
||||
from openpyxl.descriptors.base import (
|
||||
Bool,
|
||||
Convertible,
|
||||
DateTime,
|
||||
Descriptor,
|
||||
Float,
|
||||
Integer,
|
||||
Length,
|
||||
MatchPattern,
|
||||
MinMax,
|
||||
NoneSet,
|
||||
Set,
|
||||
String,
|
||||
Typed,
|
||||
)
|
||||
from openpyxl.descriptors.serialisable import Serialisable
|
||||
|
||||
|
||||
class WithDescriptors(Serialisable):
|
||||
descriptor = Descriptor[str]()
|
||||
|
||||
typed_default = Typed(expected_type=str)
|
||||
typed_not_none = Typed(expected_type=str, allow_none=False)
|
||||
typed_none = Typed(expected_type=str, allow_none=True)
|
||||
|
||||
set_tuple = Set(values=("a", 1, 0.0))
|
||||
set_list = Set(values=["a", 1, 0.0])
|
||||
set_tuple_none = Set(values=("a", 1, 0.0, None))
|
||||
|
||||
noneset_tuple = NoneSet(values=("a", 1, 0.0))
|
||||
noneset_list = NoneSet(values=["a", 1, 0.0])
|
||||
|
||||
length_tuple = Length[Tuple[str, str]](length=1) # Can't validate tuple length in a generic manner
|
||||
length_list = Length[List[str]](length=1)
|
||||
length_invalid = Length[object](length=1) # type: ignore
|
||||
|
||||
match_pattern_str_default = MatchPattern(pattern="")
|
||||
match_pattern_str = MatchPattern(pattern="", allow_none=False)
|
||||
match_pattern_str_none = MatchPattern(pattern="", allow_none=True)
|
||||
match_pattern_bytes_default = MatchPattern(pattern=b"")
|
||||
match_pattern_bytes = MatchPattern(pattern=b"", allow_none=False)
|
||||
match_pattern_bytes_none = MatchPattern(pattern=b"", allow_none=True)
|
||||
|
||||
convertible_default = Convertible(expected_type=int)
|
||||
convertible_not_none = Convertible(expected_type=int, allow_none=False)
|
||||
convertible_none = Convertible(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 = MinMax(min=0, max=0)
|
||||
minmax_float = MinMax(min=0, max=0, expected_type=float, allow_none=False)
|
||||
minmax_float_none = MinMax(min=0, max=0, expected_type=float, allow_none=True)
|
||||
minmax_int = MinMax(min=0.0, max=0.0, expected_type=int, allow_none=False)
|
||||
minmax_int_none = MinMax(min=0.0, max=0.0, expected_type=int, allow_none=True)
|
||||
|
||||
bool_default = Bool()
|
||||
bool_not_none = Bool(allow_none=False)
|
||||
bool_none = Bool(allow_none=True)
|
||||
|
||||
datetime_default = DateTime()
|
||||
datetime_not_none = DateTime(allow_none=False)
|
||||
datetime_none = DateTime(allow_none=True)
|
||||
|
||||
string_default = String()
|
||||
string_not_none = String(allow_none=False)
|
||||
string_none = String(allow_none=True)
|
||||
|
||||
float_default = Float()
|
||||
float_not_none = Float(allow_none=False)
|
||||
float_none = Float(allow_none=True)
|
||||
|
||||
integer_default = Integer()
|
||||
integer_not_none = Integer(allow_none=False)
|
||||
integer_none = Integer(allow_none=True)
|
||||
|
||||
# Test inferred annotation
|
||||
assert_type(descriptor, Descriptor[str])
|
||||
|
||||
assert_type(typed_default, Typed[str, Literal[False]])
|
||||
assert_type(typed_not_none, Typed[str, Literal[False]])
|
||||
assert_type(typed_none, Typed[str, Literal[True]])
|
||||
|
||||
assert_type(set_tuple, Set[Union[Literal["a", 1], float]]) # type: ignore[assert-type] # False-positive in mypy
|
||||
assert_type(set_list, Set[Union[str, int, float]]) # type: ignore[assert-type] # False-positive in mypy # Literals are simplified in non-tuples
|
||||
assert_type(set_tuple_none, Set[Union[Literal["a", 1, None], float]]) # type: ignore[assert-type] # False-positive in mypy
|
||||
|
||||
assert_type(noneset_tuple, NoneSet[Union[Literal["a", 1], float]]) # type: ignore[assert-type] # False-positive in mypy
|
||||
assert_type(noneset_list, NoneSet[Union[str, float]]) # type: ignore[assert-type] # False-positive in mypy# int and float are merged in generic unions
|
||||
|
||||
assert_type(length_tuple, Length[Tuple[str, str]])
|
||||
assert_type(length_list, Length[List[str]])
|
||||
|
||||
assert_type(match_pattern_str_default, MatchPattern[str, Literal[False]])
|
||||
assert_type(match_pattern_str, MatchPattern[str, Literal[False]])
|
||||
assert_type(match_pattern_str_none, MatchPattern[str, Literal[True]])
|
||||
assert_type(match_pattern_bytes_default, MatchPattern[ReadableBuffer, Literal[False]])
|
||||
assert_type(match_pattern_bytes, MatchPattern[ReadableBuffer, Literal[False]])
|
||||
assert_type(match_pattern_bytes_none, MatchPattern[ReadableBuffer, Literal[True]])
|
||||
|
||||
assert_type(convertible_default, Convertible[int, Literal[False]])
|
||||
assert_type(convertible_not_none, Convertible[int, Literal[False]])
|
||||
assert_type(convertible_none, Convertible[int, Literal[True]])
|
||||
|
||||
assert_type(minmax_default, MinMax[float, Literal[False]])
|
||||
assert_type(minmax_float, MinMax[float, Literal[False]])
|
||||
assert_type(minmax_float_none, MinMax[float, Literal[True]])
|
||||
assert_type(minmax_int, MinMax[int, Literal[False]])
|
||||
assert_type(minmax_int_none, MinMax[int, Literal[True]])
|
||||
|
||||
assert_type(bool_default, Bool[Literal[False]])
|
||||
assert_type(bool_not_none, Bool[Literal[False]])
|
||||
assert_type(bool_none, Bool[Literal[True]])
|
||||
|
||||
assert_type(datetime_default, DateTime[Literal[False]])
|
||||
assert_type(datetime_not_none, DateTime[Literal[False]])
|
||||
assert_type(datetime_none, DateTime[Literal[True]])
|
||||
|
||||
assert_type(string_default, String[Literal[False]])
|
||||
assert_type(string_not_none, String[Literal[False]])
|
||||
assert_type(string_none, String[Literal[True]])
|
||||
|
||||
assert_type(float_default, Float[Literal[False]])
|
||||
assert_type(float_not_none, Float[Literal[False]])
|
||||
assert_type(float_none, Float[Literal[True]])
|
||||
|
||||
assert_type(integer_default, Integer[Literal[False]])
|
||||
assert_type(integer_not_none, Integer[Literal[False]])
|
||||
assert_type(integer_none, Integer[Literal[True]])
|
||||
|
||||
|
||||
with_descriptors = WithDescriptors()
|
||||
|
||||
|
||||
# Test with missing subclass
|
||||
class NotSerialisable:
|
||||
descriptor = Descriptor[Any]()
|
||||
|
||||
|
||||
NotSerialisable().descriptor = None # type: ignore
|
||||
|
||||
|
||||
# Test with Strict subclass
|
||||
class WithDescriptorsStrict(Strict):
|
||||
descriptor = Descriptor[Any]()
|
||||
|
||||
|
||||
WithDescriptorsStrict().descriptor = None
|
||||
|
||||
|
||||
# Test getters
|
||||
assert_type(with_descriptors.descriptor, str)
|
||||
|
||||
assert_type(with_descriptors.typed_not_none, str) # type: ignore[assert-type] # False-positive in mypy
|
||||
assert_type(with_descriptors.typed_none, Union[str, None])
|
||||
|
||||
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.length_tuple, Tuple[str, str])
|
||||
assert_type(with_descriptors.length_list, List[str])
|
||||
|
||||
assert_type(with_descriptors.match_pattern_str, str) # type: ignore[assert-type] # False-positive in mypy
|
||||
assert_type(with_descriptors.match_pattern_str_none, Union[str, None])
|
||||
assert_type(with_descriptors.match_pattern_bytes, ReadableBuffer) # type: ignore[assert-type] # False-positive in mypy
|
||||
assert_type(with_descriptors.match_pattern_bytes_none, Union[ReadableBuffer, None])
|
||||
|
||||
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.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.datetime_not_none, datetime) # type: ignore[assert-type] # False-positive in mypy
|
||||
assert_type(with_descriptors.datetime_none, Union[datetime, 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)
|
||||
with_descriptors.descriptor = ""
|
||||
with_descriptors.descriptor = None # type: ignore
|
||||
with_descriptors.descriptor = 0 # type: ignore
|
||||
|
||||
|
||||
with_descriptors.typed_not_none = ""
|
||||
with_descriptors.typed_not_none = None # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy
|
||||
with_descriptors.typed_not_none = 0 # type: ignore
|
||||
|
||||
with_descriptors.typed_none = ""
|
||||
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
|
||||
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_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_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.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_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
|
||||
|
||||
|
||||
# NOTE: Can't validate tuple length in a generic manner
|
||||
with_descriptors.length_tuple = ("a", "a")
|
||||
with_descriptors.length_tuple = None # type: ignore
|
||||
with_descriptors.length_tuple = ["a", "a"] # type: ignore
|
||||
with_descriptors.length_tuple = "" # type: ignore
|
||||
|
||||
with_descriptors.length_list = ["a", "a"]
|
||||
with_descriptors.length_list = None # type: ignore
|
||||
with_descriptors.length_list = ("a", "a") # type: ignore
|
||||
with_descriptors.length_list = "" # type: ignore
|
||||
|
||||
|
||||
with_descriptors.match_pattern_str = ""
|
||||
with_descriptors.match_pattern_str = None # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy
|
||||
with_descriptors.match_pattern_str = b"" # type: ignore
|
||||
with_descriptors.match_pattern_str = 0 # type: ignore
|
||||
|
||||
with_descriptors.match_pattern_str_none = ""
|
||||
with_descriptors.match_pattern_str_none = None
|
||||
with_descriptors.match_pattern_str_none = b"" # type: ignore
|
||||
with_descriptors.match_pattern_str_none = 0 # type: ignore
|
||||
|
||||
with_descriptors.match_pattern_bytes = b""
|
||||
with_descriptors.match_pattern_bytes = None # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy
|
||||
with_descriptors.match_pattern_bytes = "" # type: ignore
|
||||
with_descriptors.match_pattern_bytes = 0 # type: ignore
|
||||
|
||||
with_descriptors.match_pattern_bytes_none = b""
|
||||
with_descriptors.match_pattern_bytes_none = None
|
||||
with_descriptors.match_pattern_bytes_none = "" # type: ignore
|
||||
with_descriptors.match_pattern_bytes_none = 0 # type: ignore
|
||||
|
||||
|
||||
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_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.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_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_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_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.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_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.datetime_not_none = datetime(0, 0, 0)
|
||||
with_descriptors.datetime_not_none = ""
|
||||
with_descriptors.datetime_not_none = None # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy
|
||||
with_descriptors.datetime_not_none = 0 # type: ignore
|
||||
with_descriptors.datetime_not_none = date(0, 0, 0) # type: ignore
|
||||
with_descriptors.datetime_not_none = time() # type: ignore
|
||||
|
||||
with_descriptors.datetime_none = datetime(0, 0, 0)
|
||||
with_descriptors.datetime_none = ""
|
||||
with_descriptors.datetime_none = None
|
||||
with_descriptors.datetime_none = 0 # type: ignore
|
||||
with_descriptors.datetime_none = date(0, 0, 0) # type: ignore
|
||||
with_descriptors.datetime_none = time() # type: ignore
|
||||
|
||||
|
||||
with_descriptors.string_not_none = ""
|
||||
with_descriptors.string_not_none = None # pyright: ignore[reportGeneralTypeIssues] # false negative in mypy
|
||||
with_descriptors.string_not_none = 0 # type: ignore
|
||||
|
||||
with_descriptors.string_none = ""
|
||||
with_descriptors.string_none = None
|
||||
with_descriptors.string_none = 0 # type: ignore
|
||||
|
||||
|
||||
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_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 positive(?) 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_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 positive(?) in pyright and mypy
|
||||
Reference in New Issue
Block a user