Skip to content

Commit

Permalink
fixed _ZipResult fillvalue bug (apache#26499)
Browse files Browse the repository at this point in the history
  • Loading branch information
rjmcginness committed Sep 26, 2022
1 parent 8413cb1 commit ebff0dd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions airflow/models/xcom_arg.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,9 +422,6 @@ class _ZipResult(Sequence):
def __init__(self, values: Sequence[Sequence | dict], *, fillvalue: Any = NOTSET) -> None:
self.values = values
self.fillvalue = fillvalue
# use the generator here, rather than in __len__ to improve efficiency
lengths = (len(v) for v in self.values)
self.length = min(lengths) if isinstance(self.fillvalue, ArgNotSet) else max(lengths)

@staticmethod
def _get_or_fill(container: Sequence | dict, index: Any, fillvalue: Any) -> Any:
Expand All @@ -439,7 +436,10 @@ def __getitem__(self, index: Any) -> Any:
return tuple(self._get_or_fill(value, index, self.fillvalue) for value in self.values)

def __len__(self) -> int:
return self.length
lengths = (len(v) for v in self.values)
if isinstance(self.fillvalue, ArgNotSet):
return min(lengths)
return max(lengths)


class ZipXComArg(XComArg):
Expand Down

0 comments on commit ebff0dd

Please sign in to comment.