m-morozov-kw opened a new issue, #33189: URL: https://github.com/apache/beam/issues/33189
### What happened? Test env details: Python 3.11.3 Beam SDK version: 2.60.0 Hello! We want to use generic types as a type annotation for elements in Pardo in Python SDK to improve code readability, but it seems like Test Runner doesn't support that. Are there any options for how we can work around that? Please find the reproduction snippet: Create a file like /tmp/test_pardo.py ```python import apache_beam as beam from typing import TypeVar, Generic from slp_utilities import T from apache_beam.testing.util import assert_that, equal_to from apache_beam.testing.test_pipeline import TestPipeline T = TypeVar("T") class ResultContainer(Generic[T]): def __init__(self, payload: T) -> None: self.payload = payload class SomeDoFn(beam.DoFn): def process(self, data: ResultContainer[int]): yield data.payload + 1 def test_pardo(): with TestPipeline() as p: output = p | beam.Create([ResultContainer(1)]) | beam.ParDo(SomeDoFn()) assert_that( label="check result", actual=output, matcher=equal_to([2]), ) ``` Run it as a test ```sh pytest /tmp/test_pardo.py ``` Expected: test passes Actual behavior: ```sh def __subclasscheck__(self, cls): > raise TypeError("Subscripted generics cannot be used with" " class and instance checks") E TypeError: Subscripted generics cannot be used with class and instance checks ``` Thank you ### 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: github-unsubscr...@beam.apache.org.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org