Skip to content

Use get_app_model instead of get_app for napari>=0.5.4 #103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 7, 2024

Conversation

dalthviz
Copy link
Member

Hi there, as part of napari/napari#6054 usage of get_app is being deprecated ( over PR napari/napari#7269 ). This PR changes things to use get_app_model instead of get_app. It also bumps the napari version constraint to >=0.5.4

@@ -7,7 +7,7 @@
from app_model.types import CommandRule, MenuItem

# TODO: This will be made public in some future napari version
from napari._app_model import get_app
from napari._app_model import get_app_model
Copy link
Member

Choose a reason for hiding this comment

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

If we use a try-except here, we will be compatible with older versions of napari, before the deprecation:

Suggested change
from napari._app_model import get_app_model
try:
from napari._app_model import get_app_model
except ImportError:
from napari._app_model import get_app as get_app_model

@Czaki what do you think? Then I think we can just merge this and release?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I prefer to use packaging and

from packaging.version import parse as parse_version 
from importlib.metadata import version

if parse_version(version('napari')) >= parse_version('0.5.4'):
    from napari._app_model import get_app_model
else:
    from napari._app_model import get_app as get_app_model

It allows for simpler found code that may be dropped when dropping support of older napari releases.

@dalthviz dalthviz marked this pull request as ready for review October 23, 2024 15:33
@@ -137,6 +137,8 @@ def test_zoom_and_dimensions():
increase_dimensions_left(viewer)
increase_dimensions_right(viewer)

viewer.close()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe make_napari_viewer fixture?

@jni jni changed the title Use get_app_model instead of get_app Use get_app_model instead of get_app for napari>=0.5.4 Nov 7, 2024
@jni jni merged commit cd96bf0 into napari:main Nov 7, 2024
10 checks passed
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.

3 participants