summaryrefslogtreecommitdiff
path: root/scripts/dev/pylint_checkers/qute_pylint/config.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/dev/pylint_checkers/qute_pylint/config.py')
-rw-r--r--scripts/dev/pylint_checkers/qute_pylint/config.py25
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."""