summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog2
-rw-r--r--pylint/checkers/classes.py8
-rw-r--r--pylint/test/functional/method_hidden.py23
3 files changed, 33 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index c383364ee..c5556655d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -266,6 +266,8 @@ Release date: |TBA|
Fixes #2102
+ * Fix 'method-hidden' raised when assigning to a property or data descriptor.
+
What's New in Pylint 1.9?
=========================
diff --git a/pylint/checkers/classes.py b/pylint/checkers/classes.py
index dd5f6b89e..6c67be558 100644
--- a/pylint/checkers/classes.py
+++ b/pylint/checkers/classes.py
@@ -769,6 +769,14 @@ a metaclass class method.'}
# attribute affectation will either call a setter or raise
# an attribute error, anyway not hiding the function
return
+ try:
+ for infered in decorator.infer():
+ if (isinstance(infered, astroid.ClassDef)
+ and infered.getattr('__get__')
+ and infered.getattr('__set__')):
+ return
+ except (astroid.InferenceError, astroid.AttributeInferenceError):
+ pass
# check if the method is hidden by an attribute
try:
overridden = klass.instance_attr(node.name)[0] # XXX
diff --git a/pylint/test/functional/method_hidden.py b/pylint/test/functional/method_hidden.py
index e0588aff5..a0ee991cb 100644
--- a/pylint/test/functional/method_hidden.py
+++ b/pylint/test/functional/method_hidden.py
@@ -14,3 +14,26 @@ class Cdef(Abcd):
"""test
"""
print(self)
+
+class CustomProperty:
+ """dummy"""
+ def __init__(self, _):
+ pass
+
+ def __get__(self, obj, __):
+ if not obj:
+ return self
+ return 5
+
+ def __set__(self, _, __):
+ pass
+
+class Ddef:
+ """dummy"""
+ def __init__(self):
+ self.five = "five"
+
+ @CustomProperty
+ def five(self):
+ """Always 5."""
+ return self