diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2016-01-18 13:49:59 +0200 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2016-01-18 13:49:59 +0200 |
commit | 319c79d9b4e15e6600dd055370b6ad6e6392592f (patch) | |
tree | d415af838e288959777da559cbf8dbc07908633f /pylint/checkers/classes.py | |
parent | b0f6c33ca8f69fb866297ff40eda565fc46447b2 (diff) | |
download | pylint-git-319c79d9b4e15e6600dd055370b6ad6e6392592f.tar.gz |
Catch more cases as not proper iterables for __slots__
Close issue #775
Diffstat (limited to 'pylint/checkers/classes.py')
-rw-r--r-- | pylint/checkers/classes.py | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/pylint/checkers/classes.py b/pylint/checkers/classes.py index f92c2888d..c8e142ed7 100644 --- a/pylint/checkers/classes.py +++ b/pylint/checkers/classes.py @@ -35,7 +35,7 @@ from pylint.checkers.utils import ( is_attr_protected, node_frame_class, is_builtin_object, decorated_with_property, unimplemented_abstract_methods, decorated_with, class_is_abstract, - safe_infer, has_known_bases) + safe_infer, has_known_bases, is_iterable, is_comprehension) from pylint.utils import deprecated_option, get_global_option @@ -43,7 +43,6 @@ if sys.version_info >= (3, 0): NEXT_METHOD = '__next__' else: NEXT_METHOD = 'next' -ITER_METHODS = ('__iter__', '__getitem__') INVALID_BASE_CLASSES = {'bool', 'range', 'slice', 'memoryview'} @@ -518,13 +517,9 @@ a metaclass class method.'} return for slots in node.igetattr('__slots__'): # check if __slots__ is a valid type - for meth in ITER_METHODS: - try: - slots.getattr(meth) - break - except astroid.NotFoundError: - continue - else: + if slots is astroid.YES: + continue + if not is_iterable(slots) and not is_comprehension(slots): self.add_message('invalid-slots', node=node) continue |