-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Require default arguments to type check only when not specified at the call site? #1721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
You should be able to solve this using |
There are two separate issues here.
|
Change ItemT and CompressedItemT to Any. See python/mypy#1721.
Change ItemT and CompressedItemT to Any. See python/mypy#1721.
Change ItemT and CompressedItemT to Any. See python/mypy#1721.
Consider this function (It is a simplified version of a function in Zulip).
This works as expected (see complete example here).
Compression can be useful, but I usually don't require it. So in most cases,
CItemT
will be the same asItemT
and I'll passlambda x: x
ascompress
anddecompress
.However, if I add default values to compress and decompress like this:
def fetch(key, data, cache, compress=lambda x: x, decompress=lambda x: x)
:I get these errors:
I think if I use default values for
compress
anddecompress
, mypy should not give errors. It should instead enforceCItemT
to be the same asItemT
at the place where I'm calling this function using default arguments forcompress
anddecompress
.This behavior has recently come up. It was not present in mypy 0.4.2.
The text was updated successfully, but these errors were encountered: