enthought / traits

Observable typed attributes for Python classes
Other
432 stars 85 forks source link

MAINT: replace deprecated version check for traitsui #1746

Closed homosapien-lcy closed 1 year ago

homosapien-lcy commented 1 year ago

In traitsui, traitsui.version has been deprecated and should be replaced with importlib.metadata.version('traitsui'). The deprecation warning raised have also caused test_edit_not_given in traits/traits/tests/test_configure_traits.py to fail as mentioned in #1745 . Since the version check is a temporary check to address the dependency of traits on traits ui and is no longer need, the current PR fixed this issue by removing all version checks related to _traitsui_helpers.py. closes #1745

Checklist

homosapien-lcy commented 1 year ago

I noticed a new test error happened:

FAIL: test_check_version_error (traits.util.tests.test_traitsui_helpers.TestTraitsUIHelper)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.10.11/x64/lib/python3.10/site-packages/traits/util/tests/test_traitsui_helpers.py", line 25, in test_check_version_error
    with self.assertRaises(RuntimeError) as exception_context:
AssertionError: RuntimeError not raised

So is this deprecation error supposed to be there to be check by another test (in MacOS, this deprecation error will cause the full unittest to fail)?

dpinte commented 1 year ago

The issue is that the test still relies on the deprecated way to set the version: https://github.com/enthought/traits/blob/dcbefb4e0a94a352a199ca92b3216163b79c5366/traits/util/tests/test_traitsui_helpers.py#L24

You'll need to adapt the mock to properly change the version.

mdickinson commented 1 year ago

Thanks for looking at this, @homosapien-lcy. Actually, I think we can simply remove the version check and the test for it. This was an interim measure that was needed at some point in the past when Traits had a stronger dependence on TraitsUI than it does now.

homosapien-lcy commented 1 year ago

Thanks for looking at this, @homosapien-lcy. Actually, I think we can simply remove the version check and the test for it. This was an interim measure that was needed at some point in the past when Traits had a stronger dependence on TraitsUI than it does now.

Got it, I remove all version checks for this PR