lazarillo commented on issue #20825:
URL: https://github.com/apache/beam/issues/20825#issuecomment-1842726469
Any update on this? Or any suggestions on workarounds? I can just tell
pyright (or pylance in my case, but it's built on pyright) to ignore all of the
mistakes, but that doesn't seem ideal.
FWIW, I find errors with PValue and PCollection happening a lot. For
example:
```python
class IngestPubSub(PTransform):
def expand(self, pcoll: PCollection[bytes]):
dict_data: PCollection[dict] = pcoll | "parse json strings" >>
FlatMap(
json_load
).with_output_types(dict)
obj_data: PCollection[Person] = dict_data | "create Person objects"
>> FlatMap(
object_load, container=Person
).with_output_types(Person)
```
where `Person` is a simple dataclass. This runs fine, and there are no
errors if I remove the type hints. The type hints send the flags. But I want
them for clarity of the code base.
(For those who are curious, I use `FlatMap` instead of `Map` because I am
allowing for errors in parsing, which means I am _either_ returning a list of
length 1 with the proper object, or an empty list. If I turn that to `Map`,
then I have to allow for returning `None`, which AFAICT breaks the pipeline...
it cannot receive a `None` object.)
--
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]