Support calling dict() with positional arguments and keyword arguments or **kwargs #1391

Merged
merged 3 commits into from Apr 18, 2016

Conversation

Projects
None yet
2 participants
@JukkaL
Collaborator

JukkaL commented Apr 17, 2016

Also inherit special signature of dict. Some special cases (that are likely very rare) are not handled well. I'll create a separate issue for those. The implementation is a hack but it mostly does the right thing and is fairly simple, and a clean solution would be much more complicated (for example, a plugin system or constraint based type inference system for function signatures), so I think this is okay for now.

JukkaL added some commits Apr 16, 2016

Hack to type check keyword arguments to dict() better
This is a stop-gap solution until we implement a general plugin
system for functions, or similar.

Fix #984. Also mostly fix #1010 (except for some special cases).
Partially fix dict subclassing special case
Still cases like this are broken:

class D(Dict[S, T], Generic[T, S]): ...

Also, we don't catch all invalid uses of keyword arguments
with dict subclasses.
@JukkaL

This comment has been minimized.

Show comment
Hide comment
@JukkaL

JukkaL Apr 17, 2016

Collaborator

Previous commits (8787567 and 75d3dca) changed the stubs of dict to accept keyword arguments. This PR adds better type checking around it.

Collaborator

JukkaL commented Apr 17, 2016

Previous commits (8787567 and 75d3dca) changed the stubs of dict to accept keyword arguments. This PR adds better type checking around it.

@gvanrossum gvanrossum merged commit 5d2dfce into master Apr 18, 2016

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@gvanrossum gvanrossum deleted the dict-signatures branch Apr 20, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment