diff options
author | cpopa <devnull@localhost> | 2013-10-08 19:21:28 +0300 |
---|---|---|
committer | cpopa <devnull@localhost> | 2013-10-08 19:21:28 +0300 |
commit | 7930f6685c0b4706b0ca9fa1c910049dea7913ee (patch) | |
tree | 67e6d122bf084056dcf58219b8f76b19d3329360 | |
parent | 8cfc7f6be64bc107beea841f61680c7111d3d9bf (diff) | |
download | pylint-7930f6685c0b4706b0ca9fa1c910049dea7913ee.tar.gz |
Allow get_argument_from_call to retrieve the first positional argument.
-rw-r--r-- | checkers/utils.py | 4 | ||||
-rw-r--r-- | test/unittest_checkers_utils.py | 4 |
2 files changed, 5 insertions, 3 deletions
diff --git a/checkers/utils.py b/checkers/utils.py index 68b5469..5e028f2 100644 --- a/checkers/utils.py +++ b/checkers/utils.py @@ -394,10 +394,10 @@ def get_argument_from_call(callfunc_node, position=None, keyword=None): :raises NoSuchArgumentError: if no argument at the provided position or with the provided keyword. """ - if not position and not keyword: + if position is None and keyword is None: raise ValueError('Must specify at least one of: position or keyword.') try: - if position and not isinstance(callfunc_node.args[position], astroid.Keyword): + if position is not None and not isinstance(callfunc_node.args[position], astroid.Keyword): return callfunc_node.args[position] except IndexError as error: raise NoSuchArgumentError(error) diff --git a/test/unittest_checkers_utils.py b/test/unittest_checkers_utils.py index 683f6b9..f7b0e80 100644 --- a/test/unittest_checkers_utils.py +++ b/test/unittest_checkers_utils.py @@ -65,7 +65,9 @@ class UtilsTC(unittest.TestCase): utils.get_argument_from_call(node, position=1) with self.assertRaises(ValueError): utils.get_argument_from_call(node, None, None) - + + name = utils.get_argument_from_call(node, position=0) + self.assertEqual(name.name, 'a') if __name__ == '__main__': unittest.main() |