nchint opened a new issue, #36592:
URL: https://github.com/apache/beam/issues/36592
### What happened?
This bug is seen on `apache-beam==2.63.0`
Constructing a simple pipeline where a function with an additional, optional
arg is a `UnionType` with the pipe operator results in the following exception
```python
import apache_beam as beam
def func(x: int, y: int | None = None):
return x
with beam.Pipeline() as p:
(p
| beam.Create([1])
| beam.Map(func))
```
```
Traceback (most recent call last):
File "/Users/chintala/Downloads/./test.py", line 9, in <module>
(p
^
File
"/Users/chintala/builds/master/build/internal/lib/python3.11/site-packages/apache_beam/pvalue.py",
line 138, in __or__
return self.pipeline.apply(ptransform, self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File
"/Users/chintala/builds/master/build/internal/lib/python3.11/site-packages/apache_beam/pipeline.py",
line 781, in apply
transform.type_check_inputs(pvalueish)
File
"/Users/chintala/builds/master/build/internal/lib/python3.11/site-packages/apache_beam/transforms/ptransform.py",
line 960, in type_check_inputs
if not typehints.is_consistent_with(bindings.get(arg, typehints.Any),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File
"/Users/chintala/builds/master/build/internal/lib/python3.11/site-packages/apache_beam/typehints/typehints.py",
line 1317, in is_consistent_with
return base._consistent_with_check_(sub)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File
"/Users/chintala/builds/master/build/internal/lib/python3.11/site-packages/apache_beam/typehints/typehints.py",
line 536, in _consistent_with_check_
return any(is_consistent_with(sub, elem) for elem in self.union_types)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File
"/Users/chintala/builds/master/build/internal/lib/python3.11/site-packages/apache_beam/typehints/typehints.py",
line 536, in <genexpr>
return any(is_consistent_with(sub, elem) for elem in self.union_types)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File
"/Users/chintala/builds/master/build/internal/lib/python3.11/site-packages/apache_beam/typehints/typehints.py",
line 1323, in is_consistent_with
return issubclass(sub, base)
^^^^^^^^^^^^^^^^^^^^^
TypeError: issubclass() arg 1 must be a class
```
### Issue Priority
Priority: 2 (default / most bugs should be filed as P2)
### Issue Components
- [x] Component: Python SDK
- [ ] Component: Java SDK
- [ ] Component: Go SDK
- [ ] Component: Typescript SDK
- [ ] Component: IO connector
- [ ] Component: Beam YAML
- [ ] Component: Beam examples
- [ ] Component: Beam playground
- [ ] Component: Beam katas
- [ ] Component: Website
- [ ] Component: Infrastructure
- [ ] Component: Spark Runner
- [ ] Component: Flink Runner
- [ ] Component: Samza Runner
- [ ] Component: Twister2 Runner
- [ ] Component: Hazelcast Jet Runner
- [ ] Component: Google Cloud Dataflow Runner
--
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]