From 8491f07f568545c02ac726ad7c6dab9cc415e415 Mon Sep 17 00:00:00 2001 From: Mark Dickinson Date: Fri, 21 Jun 2024 10:41:55 +0100 Subject: [PATCH 1/5] Add event types to traits.observation.api --- traits/observation/api.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/traits/observation/api.py b/traits/observation/api.py index 28e855df8..9101eec16 100644 --- a/traits/observation/api.py +++ b/traits/observation/api.py @@ -8,6 +8,13 @@ # # Thanks for using Enthought open source! +from traits.observation.events import ( + DictChangeEvent, + ListChangeEvent, + SetChangeEvent, + TraitChangeEvent, +) + from traits.observation.exception_handling import ( pop_exception_handler, push_exception_handler, From 094dbea9cde470ca21f66eecb0601e1d84507f31 Mon Sep 17 00:00:00 2001 From: Mark Dickinson Date: Fri, 21 Jun 2024 10:53:26 +0100 Subject: [PATCH 2/5] Add changelog entry --- ...5210_mdickinson_add_event_types_to_api.rst | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 changelog.d/20240621_105210_mdickinson_add_event_types_to_api.rst diff --git a/changelog.d/20240621_105210_mdickinson_add_event_types_to_api.rst b/changelog.d/20240621_105210_mdickinson_add_event_types_to_api.rst new file mode 100644 index 000000000..6293b9767 --- /dev/null +++ b/changelog.d/20240621_105210_mdickinson_add_event_types_to_api.rst @@ -0,0 +1,36 @@ +.. A new scriv changelog fragment. +.. +.. Uncomment the header that is right (remove the leading dots). +.. +.. Removed +.. ------- +.. +.. - A bullet item for the Removed category. +.. +Added +----- + +- Event types for the ``event`` received by observers have been made + available in ``traits.observation.api``. This is useful for those + wanting to use the types in type annotations. + +.. Changed +.. ------- +.. +.. - A bullet item for the Changed category. +.. +.. Deprecated +.. ---------- +.. +.. - A bullet item for the Deprecated category. +.. +.. Fixed +.. ----- +.. +.. - A bullet item for the Fixed category. +.. +.. Security +.. -------- +.. +.. - A bullet item for the Security category. +.. From 809b830dda6d419bca31b426ab38da1c286037c1 Mon Sep 17 00:00:00 2001 From: Mark Dickinson Date: Fri, 21 Jun 2024 11:05:04 +0100 Subject: [PATCH 3/5] Ensure that the tests exercise the imports --- traits/observation/tests/test_dict_change_event.py | 6 ++---- traits/observation/tests/test_list_change_event.py | 6 ++---- traits/observation/tests/test_set_change_event.py | 6 ++---- traits/observation/tests/test_trait_change_event.py | 6 ++---- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/traits/observation/tests/test_dict_change_event.py b/traits/observation/tests/test_dict_change_event.py index 6a23d5aa2..7b1fe226b 100644 --- a/traits/observation/tests/test_dict_change_event.py +++ b/traits/observation/tests/test_dict_change_event.py @@ -10,10 +10,8 @@ import unittest -from traits.observation._dict_change_event import ( - DictChangeEvent, - dict_event_factory, -) +from traits.observation.api import DictChangeEvent +from traits.observation._dict_change_event import dict_event_factory, from traits.trait_dict_object import TraitDict diff --git a/traits/observation/tests/test_list_change_event.py b/traits/observation/tests/test_list_change_event.py index a5422bb3d..7f1a0ebee 100644 --- a/traits/observation/tests/test_list_change_event.py +++ b/traits/observation/tests/test_list_change_event.py @@ -10,10 +10,8 @@ import unittest -from traits.observation._list_change_event import ( - ListChangeEvent, - list_event_factory, -) +from traits.observation.api import ListChangeEvent +from traits.observation._list_change_event import list_event_factory from traits.trait_list_object import TraitList diff --git a/traits/observation/tests/test_set_change_event.py b/traits/observation/tests/test_set_change_event.py index 134e4b161..7554de003 100644 --- a/traits/observation/tests/test_set_change_event.py +++ b/traits/observation/tests/test_set_change_event.py @@ -10,10 +10,8 @@ import unittest -from traits.observation._set_change_event import ( - SetChangeEvent, - set_event_factory, -) +from traits.observation.api import SetChangeEvent +from traits.observation._set_change_event import set_event_factory from traits.trait_set_object import TraitSet diff --git a/traits/observation/tests/test_trait_change_event.py b/traits/observation/tests/test_trait_change_event.py index a39aa5ff1..d87e4e6ad 100644 --- a/traits/observation/tests/test_trait_change_event.py +++ b/traits/observation/tests/test_trait_change_event.py @@ -12,10 +12,8 @@ from traits.has_traits import HasTraits from traits.trait_types import Int -from traits.observation._trait_change_event import ( - trait_event_factory, - TraitChangeEvent, -) +from traits.observation.api import TraitChangeEvent +from traits.observation._trait_change_event import trait_event_factory class TestTraitChangeEvent(unittest.TestCase): From a933b5c1813dbc84d97fd01d63c7f862b7921ccb Mon Sep 17 00:00:00 2001 From: Mark Dickinson Date: Fri, 21 Jun 2024 11:05:42 +0100 Subject: [PATCH 4/5] Add PR number to changelog entry --- .../20240621_105210_mdickinson_add_event_types_to_api.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/20240621_105210_mdickinson_add_event_types_to_api.rst b/changelog.d/20240621_105210_mdickinson_add_event_types_to_api.rst index 6293b9767..34f2f1cf2 100644 --- a/changelog.d/20240621_105210_mdickinson_add_event_types_to_api.rst +++ b/changelog.d/20240621_105210_mdickinson_add_event_types_to_api.rst @@ -12,7 +12,7 @@ Added - Event types for the ``event`` received by observers have been made available in ``traits.observation.api``. This is useful for those - wanting to use the types in type annotations. + wanting to use the types in type annotations. (#1805) .. Changed .. ------- From b20301a744f684c3b0481c68635c39892a93250f Mon Sep 17 00:00:00 2001 From: Mark Dickinson Date: Fri, 21 Jun 2024 11:08:09 +0100 Subject: [PATCH 5/5] Fix trailing comma --- traits/observation/tests/test_dict_change_event.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/traits/observation/tests/test_dict_change_event.py b/traits/observation/tests/test_dict_change_event.py index 7b1fe226b..c342dd3a1 100644 --- a/traits/observation/tests/test_dict_change_event.py +++ b/traits/observation/tests/test_dict_change_event.py @@ -11,7 +11,7 @@ import unittest from traits.observation.api import DictChangeEvent -from traits.observation._dict_change_event import dict_event_factory, +from traits.observation._dict_change_event import dict_event_factory from traits.trait_dict_object import TraitDict