Skip to content

Instantly share code, notes, and snippets.

@maddrum
Last active December 5, 2023 14:54
Show Gist options
  • Save maddrum/9a42eafa1ea6c54a5df692c2e768f015 to your computer and use it in GitHub Desktop.
Save maddrum/9a42eafa1ea6c54a5df692c2e768f015 to your computer and use it in GitHub Desktop.
TypeVars
import typing
from abc import ABC
_th_base = typing.TypeVar('_th_base', bound='BaseKlass')
class BaseKlass(ABC):
def __init__(self, selected_topic):
self.selected_topics = selected_topics
@classmethod
def init_from_other(cls, reporter: typing.Type[_th_base]) -> typing.Type[_th_base]:
return cls(selected_topics=reporter.selected_topics)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment