summaryrefslogtreecommitdiff
path: root/pylint/checkers/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'pylint/checkers/utils.py')
-rw-r--r--pylint/checkers/utils.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/pylint/checkers/utils.py b/pylint/checkers/utils.py
index ba396b0..0d6a488 100644
--- a/pylint/checkers/utils.py
+++ b/pylint/checkers/utils.py
@@ -44,6 +44,7 @@ ITER_METHOD = '__iter__'
NEXT_METHOD = 'next' if six.PY2 else '__next__'
GETITEM_METHOD = '__getitem__'
SETITEM_METHOD = '__setitem__'
+DELITEM_METHOD = '__delitem__'
CONTAINS_METHOD = '__contains__'
KEYS_METHOD = 'keys'
@@ -627,6 +628,10 @@ def _supports_setitem_protocol(value):
return _hasattr(value, SETITEM_METHOD)
+def _supports_delitem_protocol(value):
+ return _hasattr(value, DELITEM_METHOD)
+
+
def _is_abstract_class_name(name):
lname = name.lower()
is_mixin = lname.endswith('mixin')
@@ -685,6 +690,10 @@ def supports_setitem(value):
return _supports_protocol(value, _supports_setitem_protocol)
+def supports_delitem(value):
+ return _supports_protocol(value, _supports_delitem_protocol)
+
+
# TODO(cpopa): deprecate these or leave them as aliases?
def safe_infer(node, context=None):
"""Return the inferred value for the given node.