Replies: 1 comment 3 replies
-
|
I think the order of the decorators might be what's tripping mypy up here, Also if I may suggest some simplifications, you are overusing The following looks more correct to me: @overload
def depends(
*dependencies: str, watch: bool = ..., on_init: bool = ...
) -> Callable[[CallableT], DependsFunc[CallableT]]:
...
@overload
def depends(
*dependencies: Parameter, watch: bool = ..., on_init: bool = ..., **kw: Parameter
) -> Callable[[CallableT], DependsFunc[CallableT]]:
...
@accept_arguments
def depends(
func: CallableT, *dependencies: Dependency, watch: bool = False, on_init: bool = False, **kw: Parameter
) -> DependsFunc[CallableT]: |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a draft annotations PR here: https://github.com/holoviz/param/pull/959/files
This is a tricky one, and I can't tell if I'm doing something wrong or if this is a bug.
There are multiple decorators here:
dependstakes afuncand several extra parameters. It is not valid as a decorator by itself because of those extra parameters.accept_argumentson top of it, it becomes a second-order decorator (takes parameters and returns a first-order decorator).This is further complicated by the fact that not all parameter combinations of
dependsare valid, and so I use@overloadto only support valid combinations. I have found some old Mypy PRs that confirm that combining a decorator with@overloadis supported.Here's what running
mypyon thedepends.pyfile produces:I'm kind of stumped here, I've been staring at this for a bit and I don't see anything wrong.
Beta Was this translation helpful? Give feedback.
All reactions