-
Notifications
You must be signed in to change notification settings - Fork 26
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
allow v2.3 in metadataversion, fallback to any string #344
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #344 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 37 37
Lines 2750 2750
=========================================
Hits 2750 2750 ☔ View full report in Codecov by Sentry. |
Thanks @tlambert03! @Czaki @nclack @andy-sweet @aganders3 do any of you know why the napari headless tests would be failing with "no Qt bindings found"? here: _____________________________ test_plugin_actions ______________________________
import os
import sys
from pathlib import Path
from warnings import warn
from napari.utils.translations import trans
try:
> from qtpy import API_NAME, QT_VERSION, QtCore
[...]
E ImportError: No Qt bindings could be found.
E
E napari requires either PyQt5 (default) or PySide2 to be installed in the environment.
E
E With pip, you can install either with:
E $ pip install -U 'napari[all]' # default choice
E $ pip install -U 'napari[pyqt5]'
E $ pip install -U 'napari[pyside2]'
E
E With conda, you need to do:
E $ conda install -c conda-forge pyqt
E $ conda install -c conda-forge pyside2
E
E Our heuristics suggest you are using 'pip' to manage your packages. (We may or may not want to merge this without fixing this issue first since it seems totally unrelated. But the failing tests might block release.) |
pretty confident this is a side effect of napari/#4991. I'll take a look at it tomorrow morning at the latest. |
yep, it is. testing napari/plugins now requires qt:
|
Yeah I thought that was supposed to be guarded but obviously we cooked something! |
A clue perhaps is that this line is specifically looking for |
this is the test that used to test this on the napari side to make sure that you could run napari tests without qt: https://github.com/napari/napari/blob/b3e15c512ea611e3a8c98f1cba0a326890d2fdb2/tox.ini#L117-L119 not sure where it is run these days |
Based on the workflow file and the run on 4991 I think As for the fix, I think we should be catching the more general |
Also note in napari's tox env for headless there is this line https://github.com/napari/napari/blob/f4641213513a13b76195e3c8bb910cbcba60ede3/tox.ini#L111 Maybe this is missed when running headless tests here in Uninstalling |
metadata_version: MetadataVersion = Field( | ||
# allow str as a fallback in case the metata-version specification has been | ||
# updated and we haven't updated the code yet | ||
metadata_version: Union[MetadataVersion, str] = Field( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we provide a validator that checks if this string is a valid version number?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume you mean is it of the general pattern X.Y? You can if you want to, but I'm not sure it matters (and could bring back the future proof problem).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So why we just don't annotate with plain str
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Czaki, you can do whatever you want. with my code above, I tried to indicate that normally this should be MetadataVersion
, but yes we allow any string. along with the provided comment it gives the reader a bit more context. If you want to remove all that and make it just str, be my guest
Makes sense, thanks for catching that @aganders3! @Czaki @jni I think it's super odd that we have |
Since the fix for the failing CI is in napari, I suggest we merge and release this. @DragaDoncila what do you think? |
@jni agreed, I'll merge now and push a tag |
# Description This pull request updates the `tox` configuration for our headless tests to keep `qtpy` in the environment when running tests, and fixes the resulting failure by updating the `_safe_register_qt_actions` function to catch a more generic `ImportError`. As we can see in [this test run](https://github.com/napari/napari/actions/runs/8382772241/job/22957514533?pr=6764), if we keep `qtpy` in the environment when running headless tests (mimicking what a user would have if they ran `pip install napari`), tests initially fail because our code was catching a more specific `ModuleNotFoundError`. Users should not have to explicitly uninstall a required dependency to make use of `headless` mode. Now with a more generic `ImportError`, headless is available with or without `qtpy` in the environment. # References See [the npe2 PR](napari/npe2#344) where this was first observed for more detail. --------- Co-authored-by: Juan Nunez-Iglesias <jni@fastmail.com>
someone recently showed me an issue validating the manifest of a napari plugin,
What happened is that PEP685 https://peps.python.org/pep-0685/ added a new spec (v2.3), and some build backends have begun to implement it. For example, hatchling (which this package was using) bumped their default version to v2.3 5 days ago: pypa/hatch@1a9c30d
This PR just relaxes the validation of metadata_version to allow for any string.
@napari/core-devs, this is something that would be important to get in soon and push a new release. Packages that use setuptools will not have this issue, but anything using hatchling after 1.22.1 (released on Mar 15) will begin to see this