Replies: 3 comments 1 reply
|
You can have two major cases:
def compose(
first: Callable[[_FirstType], _SecondType],
second: Callable[[_SecondType], _ThirdType],
) -> Callable[[_FirstType], _ThirdType]: ...
Or you can just use https://github.com/dry-python/returns 🙂 |
1 reply
|
Does len have overloads? I recall paramspec with functions with overloads is buggy. I’m unsure any type checker handles that case today. I think mypy already has a bug report for that. Edit: https://github.com/python/typeshed/blob/ef6bacab926bd16f8e336f71b5360e37be03b82e/stdlib/builtins.pyi#L1344 Len appears to not have overloads so it’s not that. I tested your examples in pyright and they both work. So this is a bug in mypy to report. |
0 replies
|
Thanks @hmc-cs-mdrissi |
0 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.
I'm trying to type function composition, and get stuck.
While the general case for
nfunctions is more difficult, for two functions this should be easy with Python 3.10's ParamSpec:This works sometimes:
But not always:
I get
mypyerrors:What am I doing wrong? Any ideas?
All reactions