- Notifications
You must be signed in to change notification settings - Fork263
Type hint a function as abstract, not needing a body#2030
-
Is there a way to hint that afunction is abstract and doesn't need a body, like with the P=ParamSpec('P')T_co=TypeVar('T_co',covariant=True)classTypedSignal(Generic[P,T_co]):def__init__(self,spec:Callable[P,T_co])->None: ...defconnect(self,handler:Callable[P,T_co])->Callable[P,T_co]: ...defsend(self,*args:P.args,**kwargs:P.kwargs)->list[tuple[Callable[P,T_co],T_co]]: ...@TypedSignaldefmy_signal(sender:SomeType,arg:OtherType)->ReturnType: ...@my_signal.connectdefmy_signal_handler(sender:SomeType,arg:OtherType)->ReturnType:# Insert real implementation At the moment, Mypy complains |
BetaWas this translation helpful?Give feedback.
All reactions
raise NotImplementedError
/--disable-error-code empty-body
/# type: ignore[empty-body]
are your best bet
Replies: 1 comment 1 reply
-
|
BetaWas this translation helpful?Give feedback.
All reactions
-
Ooh, looks like there'ssupport for module-level rules now. I guess this means I can drop |
BetaWas this translation helpful?Give feedback.
All reactions
🎉 1