diff options
| author | Claudiu Popa <cpopa@cloudbasesolutions.com> | 2014-12-06 13:41:43 +0200 |
|---|---|---|
| committer | Claudiu Popa <cpopa@cloudbasesolutions.com> | 2014-12-06 13:41:43 +0200 |
| commit | a8f764450c9a79570d1e08ab576b8be73625c7e1 (patch) | |
| tree | 38aee8a0f529baa9c0ecb8944cef761611715184 /checkers/stdlib.py | |
| parent | 35fba9d396282a747bbd49d2ed9cc22b2be3203f (diff) | |
| download | pylint-git-a8f764450c9a79570d1e08ab576b8be73625c7e1.tar.gz | |
Minimize the except block, by catching only what will raise NoSuchArgumentError.
Diffstat (limited to 'checkers/stdlib.py')
| -rw-r--r-- | checkers/stdlib.py | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/checkers/stdlib.py b/checkers/stdlib.py index 6d4c89c3c..fadb58678 100644 --- a/checkers/stdlib.py +++ b/checkers/stdlib.py @@ -138,15 +138,17 @@ class StdlibChecker(BaseChecker): def _check_open_mode(self, node): """Check that the mode argument of an open or file call is valid.""" try: - mode_arg = utils.get_argument_from_call(node, position=1, keyword='mode') - if mode_arg: - mode_arg = utils.safe_infer(mode_arg) - if (isinstance(mode_arg, astroid.Const) - and not _check_mode_str(mode_arg.value)): - self.add_message('bad-open-mode', node=node, - args=(mode_arg.value)) - except (utils.NoSuchArgumentError, TypeError): - pass + mode_arg = utils.get_argument_from_call(node, position=1, + keyword='mode') + except utils.NoSuchArgumentError: + return + if mode_arg: + mode_arg = utils.safe_infer(mode_arg) + if (isinstance(mode_arg, astroid.Const) + and not _check_mode_str(mode_arg.value)): + self.add_message('bad-open-mode', node=node, + args=mode_arg.value) + def register(linter): """required method to auto register this checker """ |
