Skip to content

Commit

Permalink
Change comment, refine general check
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmccluskey committed Nov 6, 2023
1 parent a1f920a commit dac4061
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions sdks/python/apache_beam/typehints/typehints.py
Original file line number Diff line number Diff line change
Expand Up @@ -1051,14 +1051,16 @@ def _consistent_with_check_(self, sub):
# The empty tuple is consistent with Iterator[T] for any T.
return True
# Each element in the hetrogenious tuple must be consistent with
# the iterator type.
# E.g. Tuple[A, B] < Iterable[C] if A < C and B < C.
# the collection type.
# E.g. Tuple[A, B] < Collection[C] if A < C and B < C.
return all(
is_consistent_with(elem, self.inner_type)
for elem in sub.tuple_types)
elif not isinstance(sub, TypeConstraint):
if getattr(sub, '__origin__', None) is not None:
return issubclass(sub, abc.Collection)
if getattr(sub, '__origin__', None) is not None and getattr(
sub, '__args__', None) is not None:
return issubclass(sub, abc.Collection) and is_consistent_with(
sub.__args__, self.inner_type)
return False

def __getitem__(self, type_param):
Expand Down

0 comments on commit dac4061

Please sign in to comment.