Replies: 3 comments 11 replies
-
This just looks like a bug in pylance to me, considering it thinks the first argument to |
Beta Was this translation helpful? Give feedback.
-
It turns out i've celebrated too early :/ What I missed that for simplicity reasons I've put the example in a single file. Yet in reality I want to achieve something like: application.py:
framework.py:
As the name implies - framework.py is something I am writing in advance without knowing what will be passedd to AppModule during initialisation. Therefore I believe variadic generics do fit here at the end of the day. The code as it is (with a) Is Thanks a lot. @Daverball - maybe you'll be up to reading my update. Thanks again! I've found three related tickets: |
Beta Was this translation helpful? Give feedback.
-
Implemented using
Works neat. Closing the topic, thanks @Daverball again!! |
Beta Was this translation helpful? Give feedback.
-
(Cross-posting from https://stackoverflow.com/questions/76943605/type-mismatch-for-variadic-generics-variable-in-class-init-vs-method-context)
I have a type mismatch between the same definition of variadic generic
Union[*HandlerTypes]
used in__init__
and inpet_handler
method.I want strongly typed decorators - I achieve this by using
TypeVarTuple
variadic generics. All seems to work. But there is one last problem - the type mismatch between:a)
self.handlers: list[Union[*HandlerTypes]] = []
b)
self.handlers.append(handler_func)
Though technically the type is the same
Union[*HandlerTypes]
appearantly the difference of the usage context (class init vs method) triggers the pylance error forself.handlers.append(handler_func)
:Any ideas how I could work this out? Thanks a lot in advance - hours count spent on this is closely getting to 100 :)
Full code below:
Beta Was this translation helpful? Give feedback.
All reactions