diff options
author | cpopa <devnull@localhost> | 2014-07-03 18:58:22 +0300 |
---|---|---|
committer | cpopa <devnull@localhost> | 2014-07-03 18:58:22 +0300 |
commit | f0409a7253f6b945e91ce6311062a373fc32e158 (patch) | |
tree | 75e9f16649534be33403b3727da1e315a446aae3 | |
parent | 73d20c5d57eafb7b656de222437ef47ddb1e0936 (diff) | |
download | astroid-f0409a7253f6b945e91ce6311062a373fc32e158.tar.gz |
Make islots private.
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | scoped_nodes.py | 6 | ||||
-rw-r--r-- | test/unittest_scoped_nodes.py | 1 |
3 files changed, 7 insertions, 4 deletions
@@ -5,11 +5,13 @@ Change log for the astroid package (used to be astng) * `Class.metaclass()` now handles module-level __metaclass__ declaration on python 2, and no longer looks at the __metaclass__ class attribute on python 3. + * Function nodes can detect if they are decorated with subclasses of builtin descriptors when determining their type (`classmethod` and `staticmethod`). - * Add `slots` and `islots` methods to `Class` nodes. + * Add `slots` method to `Class` nodes, for retrieving + the list of valid slots it defines. 2014-04-30 -- 1.1.1 * `Class.metaclass()` looks in ancestors when the current class diff --git a/scoped_nodes.py b/scoped_nodes.py index 88b8642..95d45a5 100644 --- a/scoped_nodes.py +++ b/scoped_nodes.py @@ -1136,8 +1136,10 @@ class Class(Statement, LocalsDictNodeNG, FilterStmtsMixin): break return klass - def islots(self): + def _islots(self): """ Return an iterator with the inferred slots. """ + if '__slots__' not in self.locals: + return for slots in self.igetattr('__slots__'): # check if __slots__ is a valid type for meth in ITER_METHODS: @@ -1184,4 +1186,4 @@ class Class(Statement, LocalsDictNodeNG, FilterStmtsMixin): @cached def slots(self): """ Return all the slots for this node. """ - return list(self.islots()) + return list(self._islots()) diff --git a/test/unittest_scoped_nodes.py b/test/unittest_scoped_nodes.py index dfcdd00..37ff3be 100644 --- a/test/unittest_scoped_nodes.py +++ b/test/unittest_scoped_nodes.py @@ -898,7 +898,6 @@ def g2(): self.assertIsInstance(first_slots[1], nodes.Const) self.assertEqual(first_slots[0].value, "a") self.assertEqual(first_slots[1].value, "b") - self.assertEqual(list(first.islots()), first_slots) second_slots = astroid['Second'].slots() self.assertEqual(len(second_slots), 1) |