MagicStack / immutables

A high-performance immutable mapping type for Python.
Other
1.14k stars 57 forks source link

Improve type annotation of Map.__init__ #34

Closed hukkin closed 4 years ago

hukkin commented 4 years ago

With the current Map.__init__ type annotation, type checkers raise errors for some perfectly valid ways to initialize a Map. Some examples are:

from immutables import Map

# 1.
Map(**{"a": 1}, b=2)

# 2.
Map(a=1, **{"b": 2}, c=3)

# 3.
Map(col=1)

None of these three is valid from a type checker point of view, but all of them are working Python code at runtime.

This PR attempts to improve Map.__init__ type annotation so that type checkers are happy with the above code.

1st1 commented 4 years ago

Looks like there's a conflict now, please rebase.

hukkin commented 4 years ago

:+1: did the rebase @1st1

1st1 commented 4 years ago

Thank you!