-
Hello everyone, I am trying to get type checking to work on my operator, but I can't seem to figure out how to properly define the handler signatures. Looking at the examples in the documentation and various other resource in this repo have tried @kopf.on.startup()
def init_memo(*, memo: kopf.Memo, **_: Any) -> None:
"""Initialize memo"""
pass as well as @kopf.on.startup()
def init_memo(memo: kopf.Memo, **_: Any) -> None:
"""Initialize memo"""
pass But mypy still complains
Is this the expected behaviour? How is type checking in operators supposed to work? Do I need to explicitly list all the possible arguments (and then silence a ton of warning about unused parameters)? I am fairly new to python typing so any explanation would be greatly appreciated. Greetings |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
No, all arguments are not needed. It seems, the problem is not with the arguments, but specifically with |
Beta Was this translation helpful? Give feedback.
No, all arguments are not needed. It seems, the problem is not with the arguments, but specifically with
memo: kopf.Memo
. The callback type is declared to also accept any kind ofobject
(defined asAnyMemo=Union[Memo, object]
), but it does not work as expected when the actual kwarg is more specific than the expected callback type. I'll take a look at how this can be improved.