Files
vscode/extensions/copilot/test/simulation/fixtures/notebook/fixing/fixing16.ipynb
T
2025-06-27 11:35:20 +02:00

998 B

In [ ]:
from abc import ABC
from dataclasses import dataclass
from typing import Generic, TypeVar

T = TypeVar('T')

@dataclass
class Msg(Generic[T]):
    data: T

class Foo:
    foo: bool

class Bar:
    bar: float

class BaseHandler(Generic[T], ABC):
    def handle(self, msg: Msg[T]):
        pass

FooBar = Foo | Bar

class FooBarHandler(BaseHandler[FooBar]):
    def handle(self, msg: Msg[FooBar]):
        pass

foobar_handler = FooBarHandler()

msg = Msg(data=Foo())
foobar_handler.handle(msg)