diff options
| author | Sylvain Th?nault <thenault@gmail.com> | 2013-10-09 11:32:34 +0200 |
|---|---|---|
| committer | Sylvain Th?nault <thenault@gmail.com> | 2013-10-09 11:32:34 +0200 |
| commit | 21927cce9de6c9c765dbade49f05a47c1cf0de2a (patch) | |
| tree | 2c96334e2da39304b2e363636dada6065c5c00d0 | |
| parent | c788c70f20aa9b08a9a2f7b4e5e6e4e48b41e296 (diff) | |
| parent | 7930f6685c0b4706b0ca9fa1c910049dea7913ee (diff) | |
| download | pylint-21927cce9de6c9c765dbade49f05a47c1cf0de2a.tar.gz | |
Merged in PCManticore/pylint (pull request #63)
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() |
