uranusjr commented on code in PR #48868:
URL: https://github.com/apache/airflow/pull/48868#discussion_r2046094469
##########
task-sdk/src/airflow/sdk/definitions/xcom_arg.py:
##########
@@ -382,21 +393,74 @@ def _get_callable_name(f: Callable | str) -> str:
return "<function>"
-class _MapResult(Sequence):
- def __init__(self, value: Sequence | dict, callables: MapCallables) ->
None:
- self.value = value
+class CallableResultMixin(Generic[T], Sequence, metaclass=ABCMeta):
+ def __init__(self, value: T, callables: MapCallables) -> None:
+ self.value = list(value.items()) if isinstance(value, dict) else value
Review Comment:
I wonder if this should be simply `list(value) if ...` instead since this is
what built-in Python functions do.
```python
x = {"a": 1, "b": 2}
for v in map(lambda v: v * 2, x):
print(v)
# aa
# bb
```
I know it’s not everyone’s favourite Python feature, but it’s what it is and
likely most people expect.
We should probably also provide a way for people to get item pairs out of a
dict (without spinning up a task).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]