What is the correct return type of the following function?
import typing
T = typing.TypeVar['T']
U = typing.TypeVar['U']
def class_factory(class_T: typing.Type[T], class_U: typing.Type[U]) -> ???:
return type(class_T.__name__ + '_x_' + class_U.__name__,
(class_T, class_U), {})
Background: I am trying to convert a normal python class T to Subject class (Subject as in the observer pattern). My idea is to create class SubjectT inheriting from both T and Subject:
import typing
T = typing.TypeVar('T')
def create_subject(class_T: typing.Type[T]) -> ???:
class result_class(Subject, class_T):
def __setattr__(self, name, value):
super().__setattr__(name, value)
self.notify() # notify observers of all changes
return result_class
This works, but my IDE does not offer any code auto-completion for result_class.