diff options
author | Florian Bruhin <me@the-compiler.org> | 2021-01-02 14:14:43 +0100 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2021-01-02 14:14:43 +0100 |
commit | 2ac0566babd1d710507ed6d5b3a16ad17dae98d8 (patch) | |
tree | 93ec4e9625630b40a227afcd90c9612f172ff807 /scripts | |
parent | 83d3f07c20b4db6ec972cf5f997714e2834b57c0 (diff) | |
download | qutebrowser-2ac0566babd1d710507ed6d5b3a16ad17dae98d8.tar.gz qutebrowser-2ac0566babd1d710507ed6d5b3a16ad17dae98d8.zip |
pylint: Make config check more intelligent
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/dev/pylint_checkers/qute_pylint/config.py | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/scripts/dev/pylint_checkers/qute_pylint/config.py b/scripts/dev/pylint_checkers/qute_pylint/config.py index 097b8ada3..7eedeb215 100644 --- a/scripts/dev/pylint_checkers/qute_pylint/config.py +++ b/scripts/dev/pylint_checkers/qute_pylint/config.py @@ -49,13 +49,24 @@ class ConfigChecker(checkers.BaseChecker): @utils.check_messages('bad-config-option') def visit_attribute(self, node): """Visit a getattr node.""" - # At the end of a config.val.foo.bar chain - if not isinstance(node.parent, astroid.Attribute): - # FIXME:conf do some proper check for this... - node_str = node.as_string() - prefix = 'config.val.' - if node_str.startswith(prefix): - self._check_config(node, node_str[len(prefix):]) + # We're only interested in the end of a config.val.foo.bar chain + if isinstance(node.parent, astroid.Attribute): + return + + if isinstance(node.parent, astroid.Call): + # Skip dynamic getattr() + func = node.parent.func + if isinstance(func, astroid.Name) and func.name == 'getattr': + return + # Handle .items() / .values() + if node.attrname in ['items', 'values']: + node = node.expr + + # FIXME:conf do some proper check for this... + node_str = node.as_string() + prefix = 'config.val.' + if node_str.startswith(prefix): + self._check_config(node, node_str[len(prefix):]) def _check_config(self, node, name): """Check that we're accessing proper config options.""" |