Skip to content

Instantly share code, notes, and snippets.

@pudo
Created October 21, 2022 10:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pudo/adae5884cb29e527b2b8860d03659f52 to your computer and use it in GitHub Desktop.
Save pudo/adae5884cb29e527b2b8860d03659f52 to your computer and use it in GitHub Desktop.
from typing import (
Generic,
Type,
TypeVar,
)
class Statement(object):
pass
S = TypeVar("S", bound=Statement)
class Bla(Generic[S]):
def __init__(
self,
statement_type: Type[S] = Statement,
):
self.statement_type = statement_type
def make(self) -> S:
return self.statement_type()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment