Skip to content

Fix Python 3.11 StrEnum Compatibility#6242

Merged
Czaki merged 2 commits intonapari:mainfrom
kne42:py3-11-str-enum-compat
Sep 23, 2023
Merged

Fix Python 3.11 StrEnum Compatibility#6242
Czaki merged 2 commits intonapari:mainfrom
kne42:py3-11-str-enum-compat

Conversation

@kne42
Copy link
Copy Markdown
Member

@kne42 kne42 commented Sep 20, 2023

in Python 3.11, using a base of class MyEnum(str, Enum) instead of class MyEnum(StrEnum) will cause it to put the enum name instead of its string value when used in an f-string

see python/cpython#100458

@github-actions github-actions bot added tests Something related to our tests topic:preferences Issues relating to the creation of new preference fields/panels labels Sep 20, 2023
@kne42 kne42 added bugfix PR with bugfix and removed topic:preferences Issues relating to the creation of new preference fields/panels tests Something related to our tests labels Sep 20, 2023
@codecov
Copy link
Copy Markdown

codecov bot commented Sep 20, 2023

Codecov Report

Merging #6242 (00c7bbe) into main (48661af) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #6242   +/-   ##
=======================================
  Coverage   91.60%   91.61%           
=======================================
  Files         583      585    +2     
  Lines       51364    51382   +18     
=======================================
+ Hits        47051    47072   +21     
+ Misses       4313     4310    -3     
Files Changed Coverage Δ
napari/_app_model/constants/_commands.py 98.68% <100.00%> (ø)
napari/_app_model/constants/_menus.py 96.42% <100.00%> (ø)
napari/components/_viewer_constants.py 100.00% <100.00%> (ø)
napari/layers/utils/_color_manager_constants.py 100.00% <100.00%> (ø)
napari/settings/_constants.py 100.00% <100.00%> (ø)
napari/utils/_tests/test_compat.py 100.00% <100.00%> (ø)
napari/utils/colormaps/colormap.py 96.38% <100.00%> (ø)
napari/utils/compat.py 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

@Czaki Czaki added this to the 0.4.19 milestone Sep 20, 2023
@Czaki Czaki added the ready to merge Last chance for comments! Will be merged in ~24h label Sep 20, 2023
@Czaki Czaki merged commit d39ddfe into napari:main Sep 23, 2023
@Czaki Czaki removed the ready to merge Last chance for comments! Will be merged in ~24h label Sep 23, 2023
kne42 added a commit to kne42/napari that referenced this pull request Sep 27, 2023
* main: (21 commits)
  [pre-commit.ci] pre-commit autoupdate (napari#6266)
  ENH Make `_open_preferences_dialog` return `PreferencesDialog` (napari#6269)
  Fix link to artifacts in update dependecies comment (napari#6270)
  ci(dependabot): bump docker/login-action from 2.1.0 to 3.0.0 (napari#6263)
  FIX add `changing` event to `EventedDict` (napari#6268)
  Restore 'V' keybinding for layer visibiltiy toggle (napari#6261)
  remove: napari.qt.progress (deprecated in 0.4.11) (napari#6252)
  Fix `ShapeList.outline` validations for `int`/list like argument and add a test (napari#6215)
  Fix nitpicks in `id` and `title` `Action` fields in samples menu (napari#6267)
  ci(dependabot): bump actions/checkout from 2 to 4 (napari#6264)
  ci(dependabot): bump actions/setup-python from 2 to 4 (napari#6201)
  Fix typing in _app_model (napari#6059)
  Update `app-model`, `dask`, `fsspec`, `hypothesis`, `imageio`, `ipython`, `jsonschema`, `matplotlib`, `numpy`, `pandas`, `pillow`, `psygnal`, `pytest`, `qtconsole`, `qtpy`, `rich`, `scipy`, `superqt`, `tensorstore`, `tifffile`, `virtualenv`, `xarray`, `zarr` (napari#6265)
  Fix upgrade dependencies wokflow (napari#6211)
  Type _WeakCounter (napari#6246)
  convert Color to string (napari#6243)
  Partially fix translations testing (napari#6014)
  Allow to use all ViewerModel kwargs in Viewer constructor (napari#6209)
  MAINT: Replace `assert np.all(? == ?)` with `assert_array_equal` (napari#6244)
  Fix Python 3.11 StrEnum Compatibility (napari#6242)
  ...
kne42 added a commit to kne42/napari that referenced this pull request Sep 28, 2023
* main: (21 commits)
  [pre-commit.ci] pre-commit autoupdate (napari#6266)
  ENH Make `_open_preferences_dialog` return `PreferencesDialog` (napari#6269)
  Fix link to artifacts in update dependecies comment (napari#6270)
  ci(dependabot): bump docker/login-action from 2.1.0 to 3.0.0 (napari#6263)
  FIX add `changing` event to `EventedDict` (napari#6268)
  Restore 'V' keybinding for layer visibiltiy toggle (napari#6261)
  remove: napari.qt.progress (deprecated in 0.4.11) (napari#6252)
  Fix `ShapeList.outline` validations for `int`/list like argument and add a test (napari#6215)
  Fix nitpicks in `id` and `title` `Action` fields in samples menu (napari#6267)
  ci(dependabot): bump actions/checkout from 2 to 4 (napari#6264)
  ci(dependabot): bump actions/setup-python from 2 to 4 (napari#6201)
  Fix typing in _app_model (napari#6059)
  Update `app-model`, `dask`, `fsspec`, `hypothesis`, `imageio`, `ipython`, `jsonschema`, `matplotlib`, `numpy`, `pandas`, `pillow`, `psygnal`, `pytest`, `qtconsole`, `qtpy`, `rich`, `scipy`, `superqt`, `tensorstore`, `tifffile`, `virtualenv`, `xarray`, `zarr` (napari#6265)
  Fix upgrade dependencies wokflow (napari#6211)
  Type _WeakCounter (napari#6246)
  convert Color to string (napari#6243)
  Partially fix translations testing (napari#6014)
  Allow to use all ViewerModel kwargs in Viewer constructor (napari#6209)
  MAINT: Replace `assert np.all(? == ?)` with `assert_array_equal` (napari#6244)
  Fix Python 3.11 StrEnum Compatibility (napari#6242)
  ...
Czaki pushed a commit that referenced this pull request Oct 17, 2023
in Python 3.11, using a base of `class MyEnum(str, Enum)` instead of
`class MyEnum(StrEnum)` will cause it to put the enum name instead of
its string value when used in an f-string

see python/cpython#100458
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix PR with bugfix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants