Skip to content

Commit

Permalink
Adjusted @deprecated decorator of AggregateNotFound class to avoid ra…
Browse files Browse the repository at this point in the history
…ising runtime warning and more simply to mark the class as deprecated so that IDEs can display class as deprecate.
  • Loading branch information
johnbywater committed Aug 22, 2024
1 parent ad6eef2 commit c6640fe
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 16 deletions.
8 changes: 8 additions & 0 deletions docs/topics/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ the underlying principles are the same, and so conversion of
code and stored events is very possible.


Version 9.3.2 (released 22 August 2024)
---------------------------------------

* Adjusted @deprecated decorator of AggregateNotFound class to avoid raising runtime
warning and more simply to mark the class as deprecated so that IDEs can display class as
deprecated.


Version 9.3.1 (released 22 August 2024)
---------------------------------------

Expand Down
4 changes: 3 additions & 1 deletion eventsourcing/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,9 @@ def close(self) -> None:
TApplication = TypeVar("TApplication", bound=Application)


@deprecated("AggregateNotFound is deprecated, use AggregateNotFoundError instead")
@deprecated(
"AggregateNotFound is deprecated, use AggregateNotFoundError instead", category=None
)
class AggregateNotFound(EventSourcingError): # noqa: N818
pass

Expand Down
30 changes: 15 additions & 15 deletions eventsourcing/tests/domain_tests/test_aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -1177,24 +1177,24 @@ def test_subclass_bank_account(self):

class TestAggregateNotFound(TestCase):
def test(self):
# Verify deprecation warning.
with warnings.catch_warnings(record=True) as w:
AggregateNotFound()
# Check we didn't break any code.
try:
raise AggregateNotFoundError
except AggregateNotFound:
pass

self.assertEqual(len(w), 1)
self.assertIs(w[-1].category, DeprecationWarning)
self.assertEqual(
"AggregateNotFound is deprecated, use AggregateNotFoundError instead",
w[-1].message.args[0],
)
# # Verify deprecation warning.
# with warnings.catch_warnings(record=True) as w:
# AggregateNotFound()
#
# self.assertEqual(len(w), 1)
# self.assertIs(w[-1].category, DeprecationWarning)
# self.assertEqual(
# "AggregateNotFound is deprecated, use AggregateNotFoundError instead",
# w[-1].message.args[0],
# )

# Verify no deprecation warning.
with warnings.catch_warnings(record=True) as w:
AggregateNotFoundError()
self.assertEqual(len(w), 0)

# Check we didn't break any code.
try:
raise AggregateNotFoundError
except AggregateNotFound:
pass

0 comments on commit c6640fe

Please sign in to comment.