commit 77b6fa86df045298564b1c0b9f66bd3d71d66d2e Author: Damian Johnson atagar@torproject.org Date: Mon Jan 21 00:36:24 2013 -0800
Making the Enum's keys() method provide a list
The 2to3 converter is evidently confused because we have a keys() method that provides a tuple rather than a list. Dictionaries provide lists via their keys() method so there's probably not a terribly compelling reason for us to do differently. --- stem/__init__.py | 4 ++-- stem/util/enum.py | 4 ++-- test/unit/util/enum.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/stem/__init__.py b/stem/__init__.py index a4bbdbd..ae72ab8 100644 --- a/stem/__init__.py +++ b/stem/__init__.py @@ -632,10 +632,10 @@ StreamStatus = stem.util.enum.UppercaseEnum( )
# StreamClosureReason is a superset of RelayEndReason -StreamClosureReason = stem.util.enum.UppercaseEnum(*(RelayEndReason.keys() + ( +StreamClosureReason = stem.util.enum.UppercaseEnum(*(RelayEndReason.keys() + [ "END", "PRIVATE_ADDR", -))) +]))
StreamSource = stem.util.enum.UppercaseEnum( "CACHE", diff --git a/stem/util/enum.py b/stem/util/enum.py index 9e36c4d..9614ee8 100644 --- a/stem/util/enum.py +++ b/stem/util/enum.py @@ -89,10 +89,10 @@ class Enum(object): """ Provides an ordered listing of the enumeration keys in this set.
- :returns: **tuple** with our enum keys + :returns: **list** with our enum keys """
- return self._keys + return list(self._keys)
def index_of(self, value): """ diff --git a/test/unit/util/enum.py b/test/unit/util/enum.py index 1f199c3..0e562b3 100644 --- a/test/unit/util/enum.py +++ b/test/unit/util/enum.py @@ -46,4 +46,4 @@ class TestEnum(unittest.TestCase): self.assertEquals(insects.LADYBUG, insects.previous(insects.FIREFLY))
# keys method - self.assertEquals(("ANT", "WASP", "LADYBUG", "FIREFLY"), insects.keys()) + self.assertEquals(["ANT", "WASP", "LADYBUG", "FIREFLY"], insects.keys())