Repository navigation
fix!: Map int enums and literals to the smallest fitting int, fix fractional integer bounds and bare typing.List - #151
Merged
Merged
Conversation
… generics before parsing their arguments
…tting int or their own dtype
…attened `Interval` parts
…ranching in `PyTypeStep`
…, which keeps the raw value tuple
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
EnumandLiteraldtypes now follow their values. Before, every enum and literal becamenw.Enum, which only takes strings. AnIntEnumorLiteral[1, 2]gave a schema that failed later:to_polars()raisedTypeErrorandto_duckdb()raisedAttributeError.Enum.IntEnum200/404 givesUInt16).Literal[True, False]givesBoolean, afloatenum givesFloat64).Flag/IntFlaggiveInt64, because their members combine into values that are not listed.Nonein aLiteralmakes the field nullable, asOptionaldoes, unlessnullableis set explicitly.typing.List,typing.Sequenceandtyping.TuplegiveList(Object)instead of raisingIndexError. Unsupported generics such asset[Foo]are skipped before their arguments are parsed, so the error namessetand notFoo.Annotated[int, Gt(-1.5)]allows-1, so it now gives a signed dtype instead ofUInt64. Bounds can beint,float,DecimalorFraction._utils.int_dtype_from_bounds, which both the enum code and the annotated-types code use.Breaking changes
IntEnum,Literal[1, 2]and plain enums with int values (includingauto()) give the smallest fitting int dtype instead ofEnum.Literal[True, False]givesBoolean).Flag/IntFlaggiveInt64.Literal["a", 1]),Literal[None]and enums without members raiseUnsupportedDTypeError. To keep such a field, set{"anyschema": {"dtype": ...}}.Literal[..., None]makes the field nullable.Known limits
list[Literal["a", None]]marks the whole column nullable, not the list items. This is the same bug asnullableis set toTruefor a column whoseOptionalis on the list elements (list[T | None]) #141.Literal[Status.ACTIVE]still gives all ofStatus's categories.UInt64max silently falls back toUInt64, asAnnotated[int, Le(huge)]already does.