Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest]
environment: [py310, py311, py312, py313]
environment: [py310, py311, py312, py313, py314]
with_optionals: [false]
include:
- os: ubuntu-latest
environment: py313-optionals
environment: py314-optionals
with_optionals: true
- os: windows-latest
environment: py313-optionals
environment: py314-optionals
with_optionals: true
steps:
- name: Checkout branch
Expand Down
24 changes: 17 additions & 7 deletions dataframely/_base_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
else:
from typing_extensions import Self

if sys.version_info >= (3, 14):
from annotationlib import Format

_MEMBER_ATTR = "__dataframely_members__"
_FILTER_ATTR = "__dataframely_filters__"

Expand Down Expand Up @@ -188,11 +191,16 @@ def _get_metadata(source: dict[str, Any]) -> Metadata:
result = Metadata()

# Get all members via the annotations
annotations = {}
if "__annotations__" in source:
for attr, kls in source["__annotations__"].items():
result.members[attr] = CollectionMeta._derive_member_info(
attr, kls, CollectionMember()
)
annotations = source["__annotations__"]
elif sys.version_info >= (3, 14):
if "__annotate_func__" in source:
annotations = source["__annotate_func__"](Format.VALUE)
for attr, kls in annotations.items():
result.members[attr] = CollectionMeta._derive_member_info(
attr, kls, CollectionMember()
)

# Get all filters by traversing the source
for attr, value in {
Expand Down Expand Up @@ -230,12 +238,14 @@ def _derive_member_info(
if not any(get_origin(arg) is None for arg in union_args):
raise AnnotationImplementationError(attr, type_annotation)

[not_none_arg] = [arg for arg in union_args if get_origin(arg) is not None]
if not issubclass(get_origin(not_none_arg), TypedLazyFrame):
not_none_args = [arg for arg in union_args if get_origin(arg) is not None]
if len(not_none_args) == 0 or not issubclass(
get_origin(not_none_args[0]), TypedLazyFrame
):
raise AnnotationImplementationError(attr, type_annotation)

return MemberInfo(
schema=get_args(not_none_arg)[0],
schema=get_args(not_none_args[0])[0],
is_optional=True,
ignored_in_filters=collection_member.ignored_in_filters,
inline_for_sampling=collection_member.inline_for_sampling,
Expand Down
Loading
Loading