-
Notifications
You must be signed in to change notification settings - Fork 127
Fix #595: Prevent TypedDict kwargs from overlapping with named parameters #665
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
base: main
Are you sure you want to change the base?
Fix #595: Prevent TypedDict kwargs from overlapping with named parameters #665
Conversation
Hi @iad1tya! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
Closes #595 This PR addresses issue #595 by adding a check in function.rs to prevent TypedDict keys in **kwargs (both direct TypedDict and Unpack[TypedDict]) from overlapping with named parameters, raising a BadFunctionDefinition error. The change is tested in typed_dict.rs with test_typed_dict_kwargs_overlap, covering direct TypedDict, Unpack[TypedDict], and a non-overlapping case. All tests pass, and test.py snapshots are included. Changes: Added overlap check in function.rs for Type::TypedDict and Type::Unpack with TypedDict inner type. |
Hm, something's off about the whitespace changes in the test file, the whole file looks changed. |
@@ -277,7 +276,7 @@ impl<'a, Ans: LookupAnswer> AnswersSolver<'a, Ans> { | |||
{ | |||
self.expr( | |||
default, | |||
Some((¶m_ty, &|| { | |||
Some((¶m_ty, &|| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this symbol looks odd, somehow ¶
got replaced by ¶
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, forgot to request changes. Back to you with some comments.
Closes #595
This PR addresses issue #595 by adding a check in
function.rs
to preventTypedDict
keys in**kwargs
(both directTypedDict
andUnpack[TypedDict]
) from overlapping with named parameters, raising aBadFunctionDefinition
error. The change is tested intyped_dict.rs
withtest_typed_dict_kwargs_overlap
, covering directTypedDict
,Unpack[TypedDict]
, and a non-overlapping case. All tests pass, andtest.py
snapshots are included.Changes:
function.rs
forType::TypedDict
andType::Unpack
withTypedDict
inner type.typed_dict.rs
withtest_typed_dict_kwargs_overlap
to verify both cases and a negative test.cargo test
andpyrefly check test.py
.@yangdanny97, please review and let me know if additional cases or changes are needed, especially for
Unpack
handling. Thanks!