Explicitly import Fury before running viz test.#163
Conversation
This is so that we avoid doing this in minimal sdist.
There was a problem hiding this comment.
Pull request overview
This PR explicitly imports the fury library before attempting to import AFQ's visualization utilities to ensure that import failures are caught early, avoiding issues in minimal sdist environments where fury may not be available.
Changes:
- Added explicit
furyimport before importingAFQ.viz.utils.Viz - Changed the exception handling to set a boolean flag
test_vizinstead of settingViztoFalse - Updated the
pytest.mark.skipifdecorator to check thetest_vizflag
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| from AFQ.viz.utils import Viz | ||
|
|
||
| test_viz = True | ||
| except ImportError: |
There was a problem hiding this comment.
When the import fails, the except block sets test_viz to False but doesn't define Viz. If the test somehow runs despite the skipif decorator, it will fail with a NameError when trying to use Viz on line 17. The except block should also set Viz to None or False to ensure the variable is always defined.
| except ImportError: | |
| except ImportError: | |
| Viz = None |
| import pytest | ||
|
|
||
| try: | ||
| import fury # noqa: F401 |
There was a problem hiding this comment.
Import of 'fury' is not used.
This is so that we avoid doing this in minimal sdist.