-
Notifications
You must be signed in to change notification settings - Fork 168
fix narrowing on dict (and typed dict) .get #1390
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?
Conversation
|
Awesome, thanks! |
|
The concern I have here is that this would apply to |
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.
Back to you with comments, I think this is a great start, just needs one more piece to make sure it doesn't have any unintended effects
|
Introduced FacetOrigin/FacetSubject to track whether facet chains came from direct subscripts or .get calls, and only reuse them when the base is a dict-like source Added runtime checks so .get-derived narrows only fire when the underlying type is a builtin dict or (partial) TypedDict |
|
Thanks! |
|
@yangdanny97 has imported this pull request. If you are a Meta employee, you can view this in D85959099. |
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.
Review automatically exported from Phabricator review in Meta.
fix #238
Taught the narrowing logic to treat dict.get("literal") calls as key facets, so truthiness and is not None checks now refine the corresponding dictionary entry
Added regression coverage for both explicit is not None and plain truthiness checks on literal-key .get calls to confirm the dictionary entry narrows as expected