-
-
Notifications
You must be signed in to change notification settings - Fork 302
Add brain module for statistics inference #2832
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
Conversation
Signed-off-by: Emmanuel Ferdman <[email protected]>
Codecov Reportβ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2832 +/- ##
=======================================
Coverage 93.36% 93.36%
=======================================
Files 91 92 +1
Lines 11115 11145 +30
=======================================
+ Hits 10377 10406 +29
- Misses 738 739 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
π New features to boost your workflow:
|
Signed-off-by: Emmanuel Ferdman <[email protected]>
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.
Nice addition!
Tests LGTM, only a comment about the use of hasattr
Signed-off-by: Emmanuel Ferdman <[email protected]>
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.
Thanks!
Type of Changes
Description
My first PR to
astroid
- hope the PR was implemented correctly.This PR adds a new brain module
brain_statistics.py
that improves inference forstatistics.quantiles()
function calls. Thestatistics.quantiles()
function has complex runtime behavior that returns lists with sizes dependent on the n parameter (specifically n-1 elements), but static analysis can only see the empty list initializations (result = []
) in the function body and cannot follow the control flow that populates these lists. This causes astroid to infer empty lists, leading to false positives in pylint's unbalanced-tuple-unpacking checker. The brain module detects calls tostatistics.quantiles()
and returnsUninferable
instead, allowing downstream tools to handle the "unknown size" case appropriately rather than acting on incorrect inference results.Example:
Relevant Pylint issue: pylint-dev/pylint#10317