Skip to content

Commit

Permalink
TagError(key, resource_id, ...) -> TagError(resource_id, key, ...).
Browse files Browse the repository at this point in the history
For #268.
  • Loading branch information
lemon24 committed Jul 24, 2022
1 parent 110e22d commit ce68258
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
7 changes: 6 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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``
Expand Down Expand Up @@ -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
------------
Expand Down
2 changes: 1 addition & 1 deletion src/reader/_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/reader/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand Down
18 changes: 11 additions & 7 deletions src/reader/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit ce68258

Please sign in to comment.