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
Typing overhaul #54
Typing overhaul #54
Conversation
One issue, though: |
I don't think this is a good idea. |
This is exactly why |
@elprans Am I understanding you correct that |
That's right. |
@elprans After playing around with this locally, I think the types need to be updated a bit more substantially than this PR addresses. I'll be submitting a new PR soon to address what I've found. |
@bryanforbes @elprans Thanks for the review. I guess this PR is made obsolete by #62, so I can close it? I think restricting the type of |
This PR aims to do three things:
Make use of type annotations
Before, only
_map
was annotated, so the type checker (Pylance in my case) wasn't picking up on it. This is done usingTYPE_CHECKING
, which is available since Python 3.5.2.Additional constraints when using
**kwargs
:Specifically, this is wrong:
so if
**kwargs
are used, the key type should be a subtype ofstr
With
dict
or any other mutable mapping, this is wrong:However, with
Map
, this is fine, it just produces a map of different type: