-
-
Notifications
You must be signed in to change notification settings - Fork 276
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
Check for call context in PartialFunction.infer_call_result
#2098
Check for call context in PartialFunction.infer_call_result
#2098
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #2098 +/- ##
==========================================
- Coverage 92.76% 92.76% -0.01%
==========================================
Files 94 94
Lines 11016 11011 -5
==========================================
- Hits 10219 10214 -5
Misses 797 797
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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.
Shouldn't this be an assert
? We're inferring a call
so callcontext
should probably be set
If that's the case then maybe that information should be encoded at the type level. Maybe |
I don't know, but it makes no sense to change the logic if we are inadvertently introducing bugs with it. This changes the behaviour of the function and feels a bit like moving Chesterton's Fence. |
Co-authored-by: DaniΓ«l van Noord <[email protected]>
for more information, see https://pre-commit.ci
I have just cleaned up the signature of |
So revert back to checking, rather than asserting? |
I don't know. Asserting might very well be correct! Or we might want a subclass where the attribute has always been set? |
PartialFunction.infer_call_result
I think this change makes sense for now. Whether CallContext must be part of the context object depends on whether or not the call is to a property. Here, this PR is only altering Here is where the CallContext is usually set if you are going through Lines 291 to 295 in 92fe829
Let's just get the mypy errors fixed π |
Although I heavily agree with this I'm also wary of adding technical debt by adding asserts and code that we don't fully understand. In this case it might be fine but I do think we should be re-evaluating on a case by case basis and not just add them everywhere. |
Agree! (I walked myself through the infer_call_result patterns before approving π .) |
Type of Changes
|
Description
Check a context's call context. Fixes four Mypy errors.