apache / apache/beam

[Improvement]: accept collections.abc.Iterable[T] as a type hint

Open
#24,052 2 comments 0 reactions 0 assignees View on GitHub
core new feature P2 python types
Dominant language
Java
Stars
8.7k
Forks
4.7k
Avg merge
1d 20h
Merged PRs (30d)
196

Description

### What happened?

Trying to use typing.Iterable[T] in Beam code works fine, but collections.abc.Iterable[T] does not.

I imagine that the special casing of the typing module should be extended to collections.abc as well.

```python
print(typehints.is_consistent_with(Iterable[str], Iterable[Any]))
> True
print(typehints.is_consistent_with(collections.abc.Iterable[str], Iterable[Any]))
> False
print(typehints.is_consistent_with(collections.abc.Iterable[str], collections.abc.Iterable[Any]))
> TypeError: issubclass() argument 2 cannot be a parameterized generic
```

### Issue Priority

Priority: 2

### Issue Component

Component: sdk-py-core

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.