mirror of
https://github.com/microsoft/vscode.git
synced 2026-09-12 11:39:57 +01:00
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
998 B
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)