diff --git a/CHANGES.rst b/CHANGES.rst index e4e389fa..4927f472 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -62,7 +62,7 @@ Unreleased * :exc:`EntryMetadataNotFoundError` * the :attr:`~Entry.object_id` property of data objects and related exceptions -* Make some of the parameters of the following positional-only: +* Make some of the parameters of the following positional-only (:issue:`268`): * :meth:`Reader.add_feed`: ``feed`` * :meth:`Reader.delete_feed`: ``feed`` @@ -94,6 +94,11 @@ Unreleased * :exc:`EntryError` (and subclasses): ``feed_url``, ``entry_id`` * :exc:`TagError` (and subclasses): ``resource_id``, ``key`` +* Swap the order of the first two arguments of :exc:`TagError` (and subclasses); + ``TagError(key, resource_id, ...)`` becomes + ``TagError(resource_id, key, ...)``. + (:issue:`268`) + Version 2.17 ------------ diff --git a/src/reader/_storage.py b/src/reader/_storage.py index 7b17bcbf..03c8108c 100644 --- a/src/reader/_storage.py +++ b/src/reader/_storage.py @@ -1139,7 +1139,7 @@ def delete_tag(self, resource_id: ResourceId, key: str) -> None: with self.get_db() as db: cursor = db.execute(query, params) - rowcount_exactly_one(cursor, lambda: TagNotFoundError(key, resource_id)) + rowcount_exactly_one(cursor, lambda: TagNotFoundError(resource_id, key)) def make_get_feeds_query( diff --git a/src/reader/core.py b/src/reader/core.py index e38eb3b0..0f918d4c 100644 --- a/src/reader/core.py +++ b/src/reader/core.py @@ -1958,7 +1958,7 @@ def get_tag( resource_id = _resource_argument(resource) return zero_or_one( (v for _, v in self._storage.get_tags(resource_id, key)), - lambda: TagNotFoundError(key, resource_id), + lambda: TagNotFoundError(resource_id, key), default, ) diff --git a/src/reader/exceptions.py b/src/reader/exceptions.py index 61b9289b..b3af3c4b 100644 --- a/src/reader/exceptions.py +++ b/src/reader/exceptions.py @@ -229,25 +229,29 @@ class TagError(ReaderError): .. versionadded:: 2.8 .. versionchanged:: 2.17 - Signature changed from ``TagError(key, object_id, message='')`` - to ``TagError(key, resource_id, message='')``. + Signature changed from ``TagError(key, object_id, ...)`` + to ``TagError(key, resource_id, ...)``. .. versionchanged:: 3.0 - The ``key`` and ``resource_id`` arguments are now positional-only. + Signature changed from ``TagError(key, resource_id, ...)`` + to ``TagError(resource_id, key, ...)``. + + .. versionchanged:: 3.0 + The ``resource_id`` and ``key`` arguments are now positional-only. """ def __init__( - self, key: str, resource_id: Tuple[str, ...], /, message: str = '' + self, resource_id: Tuple[str, ...], key: str, /, message: str = '' ) -> None: super().__init__(message) - #: The tag key. - self.key = key - #: The `resource_id` of the resource. self.resource_id = resource_id + #: The tag key. + self.key = key + @property def _str(self) -> str: parts = self.resource_id + (self.key,) diff --git a/tests/test_exceptions.py b/tests/test_exceptions.py index 390d3228..b661a656 100644 --- a/tests/test_exceptions.py +++ b/tests/test_exceptions.py @@ -66,5 +66,5 @@ def test_entry_error_str(exc_type): @pytest.mark.parametrize('exc_type', all_classes(TagError)) def test_tag_error_str(exc_type): - exc = exc_type('key', ('object',)) + exc = exc_type(('object',), 'key') assert "'object': 'key'" in str(exc)