summaryrefslogtreecommitdiff
path: root/checkers/design_analysis.py
diff options
context:
space:
mode:
authorSylvain Th?nault <sylvain.thenault@logilab.fr>2013-12-20 17:32:06 +0100
committerSylvain Th?nault <sylvain.thenault@logilab.fr>2013-12-20 17:32:06 +0100
commitc15537108d3cda1267829ea0918c64549d1500e0 (patch)
treeff4d6479860c5af05e8598faf1b8c5285b9ec955 /checkers/design_analysis.py
parent147a73a3ce8c91d61e3448fed3a8e9e763cf6750 (diff)
downloadpylint-c15537108d3cda1267829ea0918c64549d1500e0.tar.gz
drop badly-implemented-container which cause several problems in its current implementation.
Somewhat close #112 (among other reporter problems).
Diffstat (limited to 'checkers/design_analysis.py')
-rw-r--r--checkers/design_analysis.py47
1 files changed, 0 insertions, 47 deletions
diff --git a/checkers/design_analysis.py b/checkers/design_analysis.py
index f3b5882..ca201f3 100644
--- a/checkers/design_analysis.py
+++ b/checkers/design_analysis.py
@@ -26,42 +26,6 @@ import re
# regexp for ignored argument name
IGNORED_ARGUMENT_NAMES = re.compile('_.*')
-SPECIAL_METHODS = [('Context manager', set(('__enter__',
- '__exit__',))),
- ('Container', set(('__len__',
- '__getitem__',))),
- ('Mutable container', set(('__setitem__',
- '__delitem__',))),
- ]
-
-class SpecialMethodChecker(object):
- """A functor that checks for consistency of a set of special methods"""
- def __init__(self, methods_found, on_error):
- """Stores the set of __x__ method names that were found in the
- class and a callable that will be called with args to R0024 if
- the check fails
- """
- self.methods_found = methods_found
- self.on_error = on_error
-
- def __call__(self, methods_required, protocol):
- """Checks the set of method names given to __init__ against the set
- required.
-
- If they are all present, returns true.
- If they are all absent, returns false.
- If some are present, reports the error and returns false.
- """
- required_methods_found = methods_required & self.methods_found
- if required_methods_found == methods_required:
- return True
- if required_methods_found:
- required_methods_missing = methods_required - self.methods_found
- self.on_error((protocol,
- ', '.join(sorted(required_methods_found)),
- ', '.join(sorted(required_methods_missing))))
- return False
-
def class_is_abstract(klass):
"""return true if the given class node should be considered as an abstract
@@ -121,10 +85,6 @@ MSGS = {
'R0923': ('Interface not implemented',
'interface-not-implemented',
'Used when an interface class is not implemented anywhere.'),
- 'R0924': ('Badly implemented %s, implements %s but not %s',
- 'incomplete-protocol',
- 'A class implements some of the special methods for a particular \
- protocol, but not all of them')
}
@@ -289,13 +249,6 @@ class MisdesignChecker(BaseChecker):
# stop here for exception, metaclass and interface classes
if node.type != 'class':
return
- # Does the class implement special methods consitently?
- # If so, don't enforce minimum public methods.
- check_special = SpecialMethodChecker(
- special_methods, lambda args: self.add_message('R0924', node=node, args=args))
- protocols = [check_special(pmethods, pname) for pname, pmethods in SPECIAL_METHODS]
- if True in protocols:
- return
# Does the class contain more than 5 public methods ?
if nb_public_methods < self.config.min_public_methods:
self.add_message('R0903', node=node,