Skip to content

Remove conditional traitsui import (ViewElement)#1033

Merged
mdickinson merged 2 commits into
masterfrom
932-remove-traitsui-imports
Apr 28, 2020
Merged

Remove conditional traitsui import (ViewElement)#1033
mdickinson merged 2 commits into
masterfrom
932-remove-traitsui-imports

Conversation

@ievacerny
Copy link
Copy Markdown
Contributor

Closes #932

This import is no longer needed as traitsui takes care of registering ViewElement as AbstractViewElement subclass, so it is removed. Also added a test to verify that ViewElement imported from traitsui.api is indeed a subclass of AbstractViewElement.

Checklist

  • Tests
  • [ ] Update API reference (docs/source/traits_api_reference)
  • [ ] Update User manual (docs/source/traits_user_manual)
  • [ ] Update type annotation hints in traits-stubs

@mdickinson
Copy link
Copy Markdown
Member

This change means that Traits 6.1.0 will effectively require TraitsUI 7.0.0 or later. While that was definitely the intention of #932, I wonder whether this is going to cause issues for projects.

OTOH, if you're upgrading to Traits 6.1.0, it's reasonable to expect that you're also upgrading to the latest TraitsUI.

Let's do it and see if anyone screams. We just need to be sure to document that the Traits 6.1.0 / TraitsUI 6.x.0 combination won't work.

Comment thread traits/tests/test_view_elements.py
Copy link
Copy Markdown
Contributor

@corranwebster corranwebster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

def test_view_element_superclass(self):
from traitsui.api import ViewElement

self.assertIsInstance(ViewElement(), AbstractViewElement)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possible overkill, but it might be worth testing for issubclass(ViewElement, AbstractViewElement) as well. That rules out ViewElement becoming a factory function at some future point, but I think that's OK.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, in the long run, we don't want this test class here at all. The TraitsUI test suite is the right place to check that ViewElement behaves appropriately.

Copy link
Copy Markdown
Contributor Author

@ievacerny ievacerny Apr 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it useful to enforce this limitation on ViewElement? From what I see, Traits always uses isinstance check, so it should work perfectly fine even if ViewElement becomes a factory function. Unless I'm missing something

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed: all Traits cares about is that the view is an instance of AbstractViewElement, so I think it's enough to check just that here.

And again, really this check should be in TraitsUI: if there isn't a test for this in TraitsUI, we should add one. (And once it's there, we can remove this one.)

Copy link
Copy Markdown
Member

@mdickinson mdickinson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@corranwebster
Copy link
Copy Markdown
Contributor

CI won't pass until EDM has TraitsUI 7

@mdickinson
Copy link
Copy Markdown
Member

mdickinson commented Apr 27, 2020

Ah. The CI is not going to pass until we have TraitsUI 7.0 in EDM. :-( We'll have to leave this open until that happens.

FTR, the buildsystem PR is here: https://github.com/enthought/buildsystem/pull/3091

@mdickinson
Copy link
Copy Markdown
Member

TraitsUI and Pyface 7.0 are now available in EDM. Closing and re-opening to trigger new CI runs.

@mdickinson mdickinson closed this Apr 28, 2020
@mdickinson mdickinson reopened this Apr 28, 2020
@mdickinson
Copy link
Copy Markdown
Member

Houston, we have a problem: we're no longer building EDM packages for Python 3.5.

There's an open issue somewhere to extend CI beyond Python 3.6 anyway (perhaps by using plain-old pip instead of EDM). I'll make a separate PR to disable CI builds on Python 3.5.

@mdickinson
Copy link
Copy Markdown
Member

Opened #1044 to drop CI runs on Python 3.5. Once that's merged, this PR should be good to merge, too.

@mdickinson
Copy link
Copy Markdown
Member

I merged master in for #1044. Will merge this PR once the CI passes.

@mdickinson mdickinson merged commit 9ef54d8 into master Apr 28, 2020
@mdickinson mdickinson deleted the 932-remove-traitsui-imports branch April 28, 2020 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Next step in untangling Traits and TraitsUI

3 participants