Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
1c664ab
update to 3.13
willingc Jul 14, 2025
a29a814
Fix enum by wrapping functool paritial
willingc Jul 14, 2025
7cd8290
Update black version
willingc Jul 14, 2025
a0ad469
remove commented out code
willingc Jul 14, 2025
26b9853
remove commented out code
willingc Jul 14, 2025
462ad0f
update python version in github action workflow
willingc Jul 14, 2025
608837d
fix black errors
willingc Jul 14, 2025
c6ad36c
set quote for black
willingc Jul 14, 2025
c453af1
fix ruff errors
willingc Jul 14, 2025
20b5b99
update action for imageio
willingc Jul 14, 2025
2d8d75a
Update the new test to mock properly the attribute for 3.10
willingc Jul 14, 2025
6784bec
reenable ffmpeg stuff in CI and update mock
willingc Jul 14, 2025
bec8ad5
Update wrap enum method and test
willingc Jul 14, 2025
445ad3a
skip simulation tests
willingc Jul 15, 2025
2fe8a9f
skip simulation tests correctly this time
willingc Jul 15, 2025
8b0762d
Add A004 to ruff lint ignore since we want math.pow
willingc Jul 15, 2025
b899d2a
Add comment about ruff target version
willingc Jul 15, 2025
d87d4a9
Make qt version more explicit
willingc Jul 15, 2025
55b49d4
make qt in tox more explicit
willingc Jul 15, 2025
c44fae7
Update napari_animation/_enum_compat.py
willingc Jul 21, 2025
0c7deb9
update typing
willingc Jul 21, 2025
f819f70
apply review changes
willingc Jul 21, 2025
f6516ca
capitalization is hard
willingc Jul 21, 2025
4788fe1
troubleshooting
willingc Jul 21, 2025
7b5f065
make test matrix similar to original file
willingc Jul 21, 2025
663e84d
additional tox changes back to initial state
willingc Jul 22, 2025
6ad9f0e
change caps for pyside
willingc Jul 22, 2025
b6c848c
pin pytest-qt to 4.4 for pyside
willingc Jul 22, 2025
90499db
remove mac-13 and macosintel
willingc Jul 22, 2025
43f348b
remove macos python3.10 from PySide2 CI testing
willingc Jul 22, 2025
698a339
drop pyside2 on 3.10 temporarily
willingc Jul 22, 2025
af6b3b7
stop failing fast
willingc Jul 22, 2025
b286862
remove env
willingc Jul 22, 2025
515b86d
Add in peter solution for pyside
willingc Jul 22, 2025
de5ee3d
add qt version to test name
willingc Jul 22, 2025
f95f759
Test removing the nested guard for enum member availability
willingc Jul 22, 2025
b9ae48e
Improve naming of guards for enum member
willingc Jul 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
apply review changes
  • Loading branch information
willingc committed Jul 21, 2025
commit f819f7087a70649eb3052d606c7ea636d3764a8c
13 changes: 6 additions & 7 deletions napari_animation/_enum_compat.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"""Compatibility layer for enum behavior across Python versions.

Python 3.13 introduced stricter enum handling requiring `enum.member()` wrapper for callable values.
Python 3.13 introduced stricter enum handling requiring `enum.member()` wrapper for callable values. See https://docs.python.org/3/library/enum.html.
This compatibility layer detects Python version and conditionally wraps enum values.
- Python 3.10:
- Python 3.11 added `member`
- Python 3.13+: member is required.
- Python 3.13+: EnumDict is added, and member is required. See
https://docs.python.org/3/whatsnew/3.13.html#enum

Enum members have a name and a value.
"""
Expand All @@ -29,9 +30,7 @@ def wrap_enum_member(value):
"""Conditionally wrap a value with enum.member if needed."""
if _NEEDS_ENUM_MEMBER:
if not _HAS_ENUM_MEMBER:
raise RuntimeError(
f"Python {sys.version_info[:2]} requires enum.member but it's not available. "
"Please upgrade your Python installation."
)
# python 3.10 does not have member so we cannot wrap
return value
# Needed for Python 3.11+
return member(value)
return value
20 changes: 0 additions & 20 deletions napari_animation/_tests/test_enum_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,26 +110,6 @@ def mock_member(value):
assert wrapped == f"wrapped_{partial_func}"


def test_wrap_enum_member_error_case():
"""Test wrap_enum_member raises error when needed but not available."""
import pytest

def test_func(x):
return x * 2

partial_func = partial(test_func)

# Simulate Python 3.13+ without enum.member (broken environment)
with (
patch("napari_animation._enum_compat._NEEDS_ENUM_MEMBER", True),
patch("napari_animation._enum_compat._HAS_ENUM_MEMBER", False),
):
with pytest.raises(
RuntimeError, match="requires enum.member but it's not available"
):
wrap_enum_member(partial_func)


def test_easing_enum_functionality():
"""Test that the Easing enum works correctly with the compatibility fix."""
# Test that all easing functions are callable
Expand Down
21 changes: 10 additions & 11 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# For more information about tox, see https://tox.readthedocs.io/en/latest/
[tox]
envlist = py{310,311,312,313}-{linux,macos,windows}-pyqt5, py{310,311,312,313}-{linux,macos,windows}-pyqt6, py{310}-{linux,macos_x86_64,macos_arm64,windows}-pyside2, py{310}-{linux,macos_x86_64,macos_arm64,windows}-pyside6
envlist = py{310,311,312,313}-{linux,macos,windows}-pyqt5, py{310,311,312,313}-{linux,macos,windows}-pyqt6, py{310}-{linux,macos,windows}-pyside2, py{310}-{linux,macos,windows}-pyside6

[gh-actions]
python =
Expand All @@ -11,16 +11,14 @@ python =

[gh-actions:env]
PLATFORM =
macos_arm64: darwin-arm64
macos_x86_64: darwin-x86_64
linux: linux
windows: win32
ubuntu-latest: linux
macos-latest: darwin
windows-latest: win32

[testenv]
platform =
macos_arm64: darwin-arm64
macos_x86_64: darwin-x86_64
linux: linux
macos: darwin
windows: win32
passenv =
CI
Expand All @@ -36,23 +34,24 @@ deps =
pytest-xvfb ; sys_platform == 'linux'
commands = pytest -v --color=yes --cov=napari_animation --cov-report=xml

[testenv:py{310,311,312,313}-{linux,macos_x86_64,macos_arm64,windows}-pyqt5]
[testenv:py{310,311,312,313}-{linux,macos,windows}-pyqt5]
deps =
{[testenv]deps}
napari[PyQt5]

[testenv:py{310,311,312,313}-{linux,macos_x86_64,macos_arm64,windows}-pyqt6]
[testenv:py{310,311,312,313}-{linux,macos,windows}-pyqt6]
deps =
{[testenv]deps}
napari[PyQt6]

# PySide2 unavailable on Mac apple silicon arm64, and for python >=3.11
[testenv:py{310}-{linux,macos_x86_64,windows}-pyside2]
[testenv:py{310}-{linux,macos,windows}-pyside2]
deps =
{[testenv]deps}
napari[pyside2]
pytest-qt < 4.5.0

[testenv:py{310}-{linux,macos_x86_64,macos_arm64,windows}-pyside6]
[testenv:py{310}-{linux,macos,windows}-pyside6]
deps =
{[testenv]deps}
napari[PySide6]
Expand Down
Loading