| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Co-authored-by: Rebecca Chen <rchen152@gmail.com>
Co-authored-by: Rebecca Chen <rchen152@gmail.com>
… suppression formats section
Removed repeated example, fixed formatting, removed stray "the".
There was a problem hiding this comment.
Thanks for the contribution! Overall, it looks good. Just a few minor changes needed for consistency with existing tests and test results.
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM
Sorry, something went wrong.
|
@yangdanny97, this PR looks good to me. If you think it's complete, I can merge it. |
Sorry, something went wrong.
|
@yangdanny97, looking at this closer, I agree with you that Example 2 seems inconsistent. It doesn't make any sense that there should be a difference between the two cases in your code snippet above. I'm not sure what to do about this. Implementing this behavior inconsistently will require some ugly special-casing within pyright's logic — and presumably in the other type checkers as well. Rather than add Example 2 to the conformance tests, perhaps we should amend the typing spec to remove this inconsistency. Thoughts? If that sounds good to you, please update the PR to remove Example 2, and then either you or I can start a discussion in the typing forum to propose changing the spec. |
Sorry, something went wrong.
|
I had a look at Pyre's implementation. I think the error emitted for the second example is a different bug, and Pyre doesn't implement the desired behavior of banning unpacked kwargs in this situation. I'll update the results to mark Pyre as partial here, and then we should be good to go. Edit: just saw your earlier response |
Sorry, something went wrong.
Sure, I can update the PR to remove the second example until we sort out the spec. Ideally we have this check apply to all typed dict spreads, or none of them. |
Sorry, something went wrong.
Sorry, something went wrong.
Summary: Handle a case that gave a weird error in python/typing#1918 Keyword only parameters were always treated as not having defaults, which made them incompatible with notrequired typeddict items. Reviewed By: rchen152 Differential Revision: D69222079 fbshipit-source-id: 5f4ac60d5bc3f7fa5da4b3709f0364f21f8d94aa
| Back | FazBrowse Home | New Git URL |
These two examples from the typing spec don't appear to have corresponding cases in the conformance suite:
EXAMPLE 1
https://typing.readthedocs.io/en/latest/spec/callables.html#source-contains-kwargs-and-destination-doesn-t
EXAMPLE 2
https://typing.readthedocs.io/en/latest/spec/callables.html#passing-kwargs-inside-a-function-to-another-function
This PR adds 2 new test cases and updates the generated conformance output.
Pyre's output is super fishy here, it emits an error message on line 138, but it's not what I would expect. If we agree that these tests should be added, I'll dig into Pyre's behavior some more.
Example 2 I have some questions about. At a glance it seems reasonable, but I thought it was really weird to specify this requirement just for unpacked kwargs, but not typed dicts in other argument positions (which should still be susceptible to these issues due to structural typing). For example:
def func7(*, v1: int, v3: str, v2: str = "") -> None: ... def func9(x: TD2, **kwargs: Unpack[TD2]) -> None: func7(**kwargs) # not OK func7(**x) # OK according to the spec, but not safe