-
-
Notifications
You must be signed in to change notification settings - Fork 306
Bug pylint 2588 #632
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
Bug pylint 2588 #632
Changes from 7 commits
e55f105
16eb616
1f7dd68
f847792
7400abb
c5da3d2
151217c
e4e4a49
67a32eb
362832f
66c413e
f6cbb1a
b3fa94a
b85b6da
b1937b9
f13c51b
e1c899a
fd3cdad
9c17b23
99eabe2
bbc41b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1217,8 +1217,9 @@ def _filter_stmts(self, stmts, frame, offset): | |
| # want to clear previous assignments if any (hence the test on | ||
| # optional_assign) | ||
| if not (optional_assign or are_exclusive(_stmts[pindex], node)): | ||
| del _stmt_parents[pindex] | ||
| del _stmts[pindex] | ||
| if not hasattr(node, 'is_partial_function') or node.name != _stmts[pindex].name: | ||
|
||
| del _stmt_parents[pindex] | ||
| del _stmts[pindex] | ||
| if isinstance(node, AssignName): | ||
| if not optional_assign and stmt.parent is mystmt.parent: | ||
| _stmts = [] | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1697,7 +1697,7 @@ def test_infer_dict_from_keys(): | |
| assert sorted(actual_values) == ["a", "b", "c"] | ||
|
|
||
|
|
||
| class TestFunctoolsPartial: | ||
| class TestFunctoolsPartial(unittest.TestCase): | ||
|
||
| def test_invalid_functools_partial_calls(self): | ||
| ast_nodes = astroid.extract_node( | ||
| """ | ||
|
|
@@ -1741,13 +1741,15 @@ def other_test(a, b, *, c=1): | |
| partial(other_test, c=4)(1, 3) #@ | ||
| partial(other_test, 4, c=4)(4) #@ | ||
| partial(other_test, 4, c=4)(b=5) #@ | ||
| test(1, 2) #@ | ||
| partial(other_test, 1, 2)(c=3) #@ | ||
| """ | ||
| ) | ||
| expected_values = [4, 7, 7, 3, 12, 16, 32, 36] | ||
| expected_values = [4, 7, 7, 3, 12, 16, 32, 36, 3, 9] | ||
| for node, expected_value in zip(ast_nodes, expected_values): | ||
| inferred = next(node.infer()) | ||
| assert isinstance(inferred, astroid.Const) | ||
| assert inferred.value == expected_value | ||
| self.assertIsInstance(inferred, astroid.Const) | ||
| self.assertEqual(inferred.value, expected_value) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
|
|
||
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.
@hippo91 I wonder if we can extract
PartialFunctionsomehow from this module. We can useastroid.objectsfor it, and if we need to figure out if a function is partial or not, we can implement thenameproperty andqnamefunction, just like we do forSuper,FrozenSetand friends. And instead of checking ifis_partial_functionis given, we only look for.nameagainst a predefined list of elements for which to apply the condition in the mixin. Do you think that's worth it?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.
@PCManticore it looks interesting.
I work on it.