From 7c01b4b1f43ebb49082247ad6b2c9410a928e8f5 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 7 Aug 2017 18:00:38 -0500 Subject: [PATCH] fix(API): signals and frames semantics Because of what these return when iterated, they act more like a `Sequence` rather than `Mapping`, so we're changing them to actually map that. Fixes #173 BREAKING CHANGE: `session.frames` and `session.signals` no longer have `keys`, `items`, and `values`. This should impact almost no one. --- nixnet/_session/collection.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/nixnet/_session/collection.py b/nixnet/_session/collection.py index 60aa3618..7929db36 100644 --- a/nixnet/_session/collection.py +++ b/nixnet/_session/collection.py @@ -12,7 +12,7 @@ @six.add_metaclass(abc.ABCMeta) -class Collection(collections.Mapping): +class Collection(collections.Sequence): """Collection of items in a session.""" def __init__(self, handle): @@ -42,7 +42,6 @@ def __contains__(self, index): raise TypeError(index) def __getitem__(self, index): - # type: (typing.Union[int, typing.Text]) -> Item if isinstance(index, six.integer_types): name = self._list_cache[index] elif isinstance(index, six.string_types): @@ -59,6 +58,12 @@ def __getitem__(self, index): def get(self, index, default=None): # type: (typing.Union[int, typing.Text], typing.Any) -> Item + """Access an item, returning ``default`` on failure. + + Args: + index(str or int): Item name or index + default: Value to return when lookup fails + """ if isinstance(index, six.integer_types): try: name = self._list_cache[index]