Skip to content
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

dict.update() with keyword args is not supported #1031

Closed
gvanrossum opened this issue Dec 1, 2015 · 4 comments
Closed

dict.update() with keyword args is not supported #1031

gvanrossum opened this issue Dec 1, 2015 · 4 comments

Comments

@gvanrossum
Copy link
Member

Example:

a = dict(foo=42)
a.update(foo=0)

Error:

/Users/guido/mypy_tests/mypy_update.py:2: error: Unexpected keyword argument "foo" for "update" of "dict"

The work-around is pretty simple: a.update(dict(foo=0)).

@JukkaL JukkaL added the feature label Dec 1, 2015
@refi64
Copy link
Contributor

refi64 commented Dec 1, 2015

Isn't this a bug in typeshed?

@refi64
Copy link
Contributor

refi64 commented Dec 1, 2015

@gvanrossum
Copy link
Member Author

Well, I tried to fix it with an overload in typeshed (see attached diff -- I also had to add the same overload to Counter) but it didn't really work. Using the overload with keyword args requires the key type to be a string (but there's no way to express that in the stub), and the actual example was passing two values of different types. This example still elicits an error for the update() but not for the dict() call:

a = dict(foo=42, bar=False)
a.update(foo=0, bar=False)

I always get

mypy_update.py:2: error: No overload variant of "update" of "dict" matches argument types [builtins.int, builtins.bool]

Adding a type annotation (# type: Dict[str, Any]) to line 1 doesn't help.
update.diff.txt
(Off-topic: I find it ironic that GitHub doesn't support attaching files whose name ends in .diff or .patch. :-)

cortesi added a commit to cortesi/mitmproxy that referenced this issue Mar 16, 2017
We get little benefit from our mypy QA checks at the moment, because we skip
imports. This patch is what's needed to make mypy succeed with imports on a
single file: master.py

It also updates mypy to the current version, and enables a QA check.

Mypy bugs I encountered:

dict.update with kwargs not supported:

python/mypy#1031

property setters and getters must be adjacent:

python/mypy#1465
cortesi added a commit to cortesi/mitmproxy that referenced this issue Mar 16, 2017
We get little benefit from our mypy QA checks at the moment, because we skip
imports. This patch is what's needed to make mypy succeed with imports on a
single file: master.py

It also updates mypy to the current version, and enables a QA check.

Mypy bugs I encountered:

dict.update with kwargs not supported:

python/mypy#1031

property setters and getters must be adjacent:

python/mypy#1465
cortesi added a commit to cortesi/mitmproxy that referenced this issue Mar 16, 2017
We get little benefit from our mypy QA checks at the moment, because we skip
imports. This patch is what's needed to make mypy succeed with imports on a
single file: master.py

It also updates mypy to the current version, and enables a QA check.

Mypy bugs I encountered:

dict.update with kwargs not supported:

python/mypy#1031

property setters and getters must be adjacent:

python/mypy#1465
cortesi added a commit to cortesi/mitmproxy that referenced this issue Mar 16, 2017
We get little benefit from our mypy QA checks at the moment, because we skip
imports. This patch is what's needed to make mypy succeed with imports on a
single file: master.py

It also updates mypy to the current version, and enables a QA check.

Mypy bugs I encountered:

dict.update with kwargs not supported:

python/mypy#1031

property setters and getters must be adjacent:

python/mypy#1465
cortesi added a commit to cortesi/mitmproxy that referenced this issue Mar 16, 2017
We get little benefit from our mypy QA checks at the moment, because we skip
imports. This patch is what's needed to make mypy succeed with imports on a
single file: master.py

It also updates mypy to the current version, and enables a QA check.

Mypy bugs I encountered:

dict.update with kwargs not supported:

python/mypy#1031

property setters and getters must be adjacent:

python/mypy#1465
cortesi added a commit to cortesi/mitmproxy that referenced this issue Mar 16, 2017
We get little benefit from our mypy QA checks at the moment, because we skip
imports. This patch is what's needed to make mypy succeed with imports on a
single file: master.py

It also updates mypy to the current version, and enables a QA check.

Mypy bugs I encountered:

dict.update with kwargs not supported:

python/mypy#1031

property setters and getters must be adjacent:

python/mypy#1465
cortesi added a commit to cortesi/mitmproxy that referenced this issue Mar 16, 2017
We get little benefit from our mypy QA checks at the moment, because we skip
imports. This patch is what's needed to make mypy succeed with imports on a
single file: master.py

It also updates mypy to the current version, and enables a QA check.

Mypy bugs I encountered:

dict.update with kwargs not supported:

python/mypy#1031

property setters and getters must be adjacent:

python/mypy#1465
cortesi added a commit to cortesi/mitmproxy that referenced this issue Mar 18, 2017
We get little benefit from our mypy QA checks at the moment, because we skip
imports. This patch is what's needed to make mypy succeed with imports on a
single file: master.py

It also updates mypy to the current version, and enables a QA check.

Mypy bugs I encountered:

dict.update with kwargs not supported:

python/mypy#1031

property setters and getters must be adjacent:

python/mypy#1465
@JukkaL
Copy link
Collaborator

JukkaL commented May 18, 2018

This seems to work now.

@JukkaL JukkaL closed this as completed May 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants