From 154cf89f849edb86b5932ee3a43f4871dfe01c53 Mon Sep 17 00:00:00 2001 From: jmoore Date: Thu, 14 Apr 2022 08:37:32 +0200 Subject: [PATCH 1/5] Copy pre-commit from ome-zarr-py --- .isort.cfg | 2 + .pre-commit-config.yaml | 85 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 .isort.cfg create mode 100644 .pre-commit-config.yaml diff --git a/.isort.cfg b/.isort.cfg new file mode 100644 index 0000000..b46c472 --- /dev/null +++ b/.isort.cfg @@ -0,0 +1,2 @@ +[settings] +known_third_party = numpy,ome_zarr,pytest,setuptools,vispy diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..9cf5b2a --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,85 @@ +--- +repos: + + - repo: https://github.com/asottile/seed-isort-config + rev: v2.2.0 + hooks: + - id: seed-isort-config + + - repo: https://github.com/PyCQA/isort + rev: 5.10.1 + hooks: + - id: isort + + - repo: https://github.com/psf/black + rev: 22.1.0 + hooks: + - id: black + args: [--target-version=py36] + + - repo: https://github.com/asottile/pyupgrade + rev: v2.31.0 + hooks: + - id: pyupgrade + args: + - --py36-plus + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.1.0 + hooks: + - id: trailing-whitespace + exclude: .bumpversion.cfg + - id: end-of-file-fixer + exclude: tests/data/ + - id: check-json + files: \.(json)$ + - id: check-yaml + - id: fix-encoding-pragma + args: + - --remove + - id: check-case-conflict + - id: check-merge-conflict + - id: check-symlinks + - id: pretty-format-json + args: + - --autofix + + - repo: https://github.com/PyCQA/flake8 + rev: 4.0.1 + hooks: + - id: flake8 + additional_dependencies: [ + # flake8-blind-except, FIXME + flake8-builtins, + flake8-rst-docstrings, + flake8-logging-format, + ] + args: [ + # default black line length is 88 + "--max-line-length=88", + # Conflicts with black: E203 whitespace before ':' + "--ignore=E203", + "--rst-roles=class,func,ref,module,const", + ] + + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v0.931 + hooks: + - id: mypy + + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v0.931 + hooks: + - id: mypy + args: [ + --disallow-untyped-defs, + --ignore-missing-imports, + ] + exclude: tests/|setup.py + + - repo: https://github.com/adrienverge/yamllint.git + rev: v1.26.3 + hooks: + - id: yamllint + # args: [--config-data=relaxed] + # From 0fc7fcc553f6a6656545049cd87d63a9fef6f6cb Mon Sep 17 00:00:00 2001 From: jmoore Date: Thu, 14 Apr 2022 08:41:46 +0200 Subject: [PATCH 2/5] Add pre-commit badge --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2f07d7f..ef3c934 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,8 @@ [![Python Version](https://img.shields.io/pypi/pyversions/napari-ome-zarr.svg?color=green)](https://python.org) [![tests](https://github.com/ome/napari-ome-zarr/workflows/tests/badge.svg)](https://github.com/ome/napari-ome-zarr/actions) [![codecov](https://codecov.io/gh/ome/napari-ome-zarr/branch/master/graph/badge.svg)](https://codecov.io/gh/ome/napari-ome-zarr) +[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/ome/napari-ome-zarr/main.svg)](https://results.pre-commit.ci/latest/github/ome/napari-ome-zarr/main) + A reader for zarr backed OME-NGFF images. @@ -41,10 +43,10 @@ in napari:: OR in python:: import napari - + viewer = napari.Viewer() viewer.open('https://uk1s3.embassy.ebi.ac.uk/idr/zarr/v0.3/9836842.zarr/') - + napari.run() If single zarray is passed to the plugin, it will be opened without the use of From 35f9ba68e3d92623f2317e18b25af629233a5b9b Mon Sep 17 00:00:00 2001 From: jmoore Date: Thu, 14 Apr 2022 12:08:05 +0200 Subject: [PATCH 3/5] Config and code fixes to pass pre-commit --- .github/workflows/test_and_deploy.yml | 16 +-- .pre-commit-config.yaml | 8 +- docs/conf.py | 164 ++++++++++++++------------ docs/index.rst | 1 - napari_ome_zarr/__init__.py | 3 +- napari_ome_zarr/_reader.py | 27 +++-- napari_ome_zarr/_tests/test_reader.py | 2 +- requirements.txt | 2 +- setup.cfg | 4 +- setup.py | 2 - tox.ini | 8 +- 11 files changed, 126 insertions(+), 111 deletions(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index 677ac87..834a3ed 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -1,15 +1,17 @@ -# This workflows will upload a Python Package using Twine when a release is created -# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries +--- +# This workflows will upload a Python Package using Twine when a release is +# created For more information see: +# https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries name: tests -on: +on: push: branches: - master - main tags: - - "v*" # Push events to matching v*, i.e. v1.0, v20.15.10 + - "v*" # Push events to matching v*, i.e. v1.0, v20.15.10 pull_request: branches: - master @@ -33,8 +35,8 @@ jobs: with: python-version: ${{ matrix.python-version }} - # these libraries, along with pytest-xvfb (added in the `deps` in tox.ini), - # enable testing on Qt on linux + # these libraries, along with pytest-xvfb (added in the `deps` in + # tox.ini), enable testing on Qt on linux - name: Install Linux libraries if: runner.os == 'Linux' run: | @@ -69,7 +71,7 @@ jobs: deploy: # this will run when you have tagged a commit, starting with "v*" - # and requires that you have put your twine API key in your + # and requires that you have put your twine API key in your # github secrets (see readme for details) needs: [test] runs-on: ubuntu-latest diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9cf5b2a..7c07225 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: - id: isort - repo: https://github.com/psf/black - rev: 22.1.0 + rev: 22.3.0 hooks: - id: black args: [--target-version=py36] @@ -60,12 +60,14 @@ repos: # Conflicts with black: E203 whitespace before ':' "--ignore=E203", "--rst-roles=class,func,ref,module,const", + "--exclude=docs/conf.py", ] - repo: https://github.com/pre-commit/mirrors-mypy rev: v0.931 hooks: - id: mypy + exclude: tests/|setup.py|docs/conf.py - repo: https://github.com/pre-commit/mirrors-mypy rev: v0.931 @@ -75,11 +77,9 @@ repos: --disallow-untyped-defs, --ignore-missing-imports, ] - exclude: tests/|setup.py + exclude: tests/|setup.py|docs/conf.py - repo: https://github.com/adrienverge/yamllint.git rev: v1.26.3 hooks: - id: yamllint - # args: [--config-data=relaxed] - # diff --git a/docs/conf.py b/docs/conf.py index 95c8636..b4b0e94 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # napari-ome-zarr documentation build configuration file, created by # sphinx-quickstart on Thu Oct 1 00:43:18 2015. @@ -12,45 +11,45 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import sys import os import shlex +import sys # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. -#sys.path.insert(0, os.path.abspath('.')) +# sys.path.insert(0, os.path.abspath('.')) # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. -#needs_sphinx = '1.0' +# needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ - 'sphinx.ext.ifconfig', + "sphinx.ext.ifconfig", ] # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # source_suffix = ['.rst', '.md'] -source_suffix = '.rst' +source_suffix = ".rst" # The encoding of source files. -#source_encoding = 'utf-8-sig' +# source_encoding = 'utf-8-sig' # The master toctree document. -master_doc = 'index' +master_doc = "index" # General information about the project. -project = u'napari-ome-zarr' -copyright = u'2015, OME Team' -author = u'OME Team' +project = "napari-ome-zarr" +copyright = "2015, OME Team" +author = "OME Team" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -71,37 +70,37 @@ # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: -#today = '' +# today = '' # Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' +# today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. -exclude_patterns = ['_build'] +exclude_patterns = ["_build"] # The reST default role (used for this markup: `text`) to use for all # documents. -#default_role = None +# default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True +# add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). -#add_module_names = True +# add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. -#show_authors = False +# show_authors = False # The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' +pygments_style = "sphinx" # A list of ignored prefixes for module index sorting. -#modindex_common_prefix = [] +# modindex_common_prefix = [] # If true, keep warnings as "system message" paragraphs in the built documents. -#keep_warnings = False +# keep_warnings = False # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = False @@ -111,143 +110,145 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. -html_theme = 'alabaster' +html_theme = "alabaster" # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. -#html_theme_options = {} +# html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. -#html_theme_path = [] +# html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". -#html_title = None +# html_title = None # A shorter title for the navigation bar. Default is the same as html_title. -#html_short_title = None +# html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. -#html_logo = None +# html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. -#html_favicon = None +# html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +html_static_path = ["_static"] # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied # directly to the root of the documentation. -#html_extra_path = [] +# html_extra_path = [] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. -#html_last_updated_fmt = '%b %d, %Y' +# html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. -#html_use_smartypants = True +# html_use_smartypants = True # Custom sidebar templates, maps document names to template names. -#html_sidebars = {} +# html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. -#html_additional_pages = {} +# html_additional_pages = {} # If false, no module index is generated. -#html_domain_indices = True +# html_domain_indices = True # If false, no index is generated. -#html_use_index = True +# html_use_index = True # If true, the index is split into individual pages for each letter. -#html_split_index = False +# html_split_index = False # If true, links to the reST sources are added to the pages. -#html_show_sourcelink = True +# html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -#html_show_sphinx = True +# html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -#html_show_copyright = True +# html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. -#html_use_opensearch = '' +# html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = None +# html_file_suffix = None # Language to be used for generating the HTML full-text search index. # Sphinx supports the following languages: # 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' # 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' -#html_search_language = 'en' +# html_search_language = 'en' # A dictionary with options for the search language support, empty by default. # Now only 'ja' uses this config value -#html_search_options = {'type': 'default'} +# html_search_options = {'type': 'default'} # The name of a javascript file (relative to the configuration directory) that # implements a search results scorer. If empty, the default will be used. -#html_search_scorer = 'scorer.js' +# html_search_scorer = 'scorer.js' # Output file base name for HTML help builder. -htmlhelp_basename = 'napari-cookiecutterplugin_namedoc' +htmlhelp_basename = "napari-cookiecutterplugin_namedoc" # -- Options for LaTeX output --------------------------------------------- latex_elements = { -# The paper size ('letterpaper' or 'a4paper'). -#'papersize': 'letterpaper', - -# The font size ('10pt', '11pt' or '12pt'). -#'pointsize': '10pt', - -# Additional stuff for the LaTeX preamble. -#'preamble': '', - -# Latex figure (float) alignment -#'figure_align': 'htbp', + # The paper size ('letterpaper' or 'a4paper'). + #'papersize': 'letterpaper', + # The font size ('10pt', '11pt' or '12pt'). + #'pointsize': '10pt', + # Additional stuff for the LaTeX preamble. + #'preamble': '', + # Latex figure (float) alignment + #'figure_align': 'htbp', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, 'napari-cookiecutterplugin_name.tex', u'napari-\\{\\{cookiecutter.plugin\\_name\\}\\} Documentation', - u'\\{\\{cookiecutter.full\\_name\\}\\}', 'manual'), + ( + master_doc, + "napari-cookiecutterplugin_name.tex", + "napari-\\{\\{cookiecutter.plugin\\_name\\}\\} Documentation", + "\\{\\{cookiecutter.full\\_name\\}\\}", + "manual", + ), ] # The name of an image file (relative to this directory) to place at the top of # the title page. -#latex_logo = None +# latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. -#latex_use_parts = False +# latex_use_parts = False # If true, show page references after internal links. -#latex_show_pagerefs = False +# latex_show_pagerefs = False # If true, show URL addresses after external links. -#latex_show_urls = False +# latex_show_urls = False # Documents to append as an appendix to all manuals. -#latex_appendices = [] +# latex_appendices = [] # If false, no module index is generated. -#latex_domain_indices = True +# latex_domain_indices = True # -- Options for manual page output --------------------------------------- @@ -255,12 +256,17 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - (master_doc, 'napari-cookiecutterplugin_name', u'napari-ome-zarr Documentation', - [author], 1) + ( + master_doc, + "napari-cookiecutterplugin_name", + "napari-ome-zarr Documentation", + [author], + 1, + ) ] # If true, show URL addresses after external links. -#man_show_urls = False +# man_show_urls = False # -- Options for Texinfo output ------------------------------------------- @@ -269,19 +275,25 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, 'napari-cookiecutterplugin_name', u'napari-ome-zarr Documentation', - author, 'napari-cookiecutterplugin_name', 'One line description of project.', - 'Miscellaneous'), + ( + master_doc, + "napari-cookiecutterplugin_name", + "napari-ome-zarr Documentation", + author, + "napari-cookiecutterplugin_name", + "One line description of project.", + "Miscellaneous", + ), ] # Documents to append as an appendix to all manuals. -#texinfo_appendices = [] +# texinfo_appendices = [] # If false, no module index is generated. -#texinfo_domain_indices = True +# texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. -#texinfo_show_urls = 'footnote' +# texinfo_show_urls = 'footnote' # If true, do not generate a @detailmenu in the "Top" node's menu. -#texinfo_no_detailmenu = False +# texinfo_no_detailmenu = False diff --git a/docs/index.rst b/docs/index.rst index 843bb03..ce34e62 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -19,4 +19,3 @@ Indices and tables * :ref:`genindex` * :ref:`modindex` * :ref:`search` - diff --git a/napari_ome_zarr/__init__.py b/napari_ome_zarr/__init__.py index b41987a..88e5230 100644 --- a/napari_ome_zarr/__init__.py +++ b/napari_ome_zarr/__init__.py @@ -1,8 +1,7 @@ - try: from ._version import version as __version__ except ImportError: __version__ = "unknown" -from ._reader import napari_get_reader +from ._reader import napari_get_reader # noqa diff --git a/napari_ome_zarr/_reader.py b/napari_ome_zarr/_reader.py index 3b3314e..6f2e915 100644 --- a/napari_ome_zarr/_reader.py +++ b/napari_ome_zarr/_reader.py @@ -9,12 +9,11 @@ from typing import Any, Callable, Dict, Iterator, List, Optional import numpy as np -from vispy.color import Colormap - from ome_zarr.data import CHANNEL_DIMENSION from ome_zarr.io import parse_url from ome_zarr.reader import Label, Node, Reader from ome_zarr.types import LayerData, PathLike, ReaderFunction +from vispy.color import Colormap try: from napari_plugin_engine import napari_hook_implementation @@ -29,8 +28,8 @@ def napari_hook_implementation( LOGGER = logging.getLogger("napari_ome_zarr.reader") # NB: color for labels, colormap for images -METADATA_KEYS = ("name", "visible", "contrast_limits", "colormap", - "color", "metadata") +METADATA_KEYS = ("name", "visible", "contrast_limits", "colormap", "color", "metadata") + @napari_hook_implementation def napari_get_reader(path: PathLike) -> Optional[ReaderFunction]: @@ -50,18 +49,23 @@ def napari_get_reader(path: PathLike) -> Optional[ReaderFunction]: return None -def transform_properties(props=None): +def transform_properties( + props: Optional[Dict[str, Dict]] = None +) -> Optional[Dict[str, List]]: """ Transform properties Transform a dict of {label_id : {key: value, key2: value2}} with a key for every LABEL into a dict of a key for every VALUE, with a list of values for each - { - "index": [1381342, 1381343...] - "omero:roiId": [1381342, 1381343...], - "omero:shapeId": [1682567, 1682567...] - } + .. code:: + + { + "index": [1381342, 1381343...] + "omero:roiId": [1381342, 1381343...], + "omero:shapeId": [1682567, 1682567...] + } + """ if props is None: return None @@ -129,7 +133,8 @@ def f(*args: Any, **kwargs: Any) -> List[LayerData]: if x in node.metadata: metadata[x] = node.metadata[x] else: - # single channel image, so metadata just needs single items (not lists) + # single channel image, so metadata just needs + # single items (not lists) for x in METADATA_KEYS: if x in node.metadata: try: diff --git a/napari_ome_zarr/_tests/test_reader.py b/napari_ome_zarr/_tests/test_reader.py index 4b89008..409021b 100644 --- a/napari_ome_zarr/_tests/test_reader.py +++ b/napari_ome_zarr/_tests/test_reader.py @@ -2,8 +2,8 @@ import numpy as np import pytest - from ome_zarr.data import astronaut, create_zarr + from napari_ome_zarr._reader import napari_get_reader diff --git a/requirements.txt b/requirements.txt index ecf975e..d6e1198 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ --e . \ No newline at end of file +-e . diff --git a/setup.cfg b/setup.cfg index 30ddb6d..86292d8 100644 --- a/setup.cfg +++ b/setup.cfg @@ -39,6 +39,6 @@ install_requires = vispy -[options.entry_points] -napari.plugin = +[options.entry_points] +napari.plugin = napari-ome-zarr = napari_ome_zarr diff --git a/setup.py b/setup.py index aa3aba5..1f094cc 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,6 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- from setuptools import setup - # https://github.com/pypa/setuptools_scm use_scm = {"write_to": "napari_ome_zarr/_version.py"} setup(use_scm_version=use_scm) diff --git a/tox.ini b/tox.ini index ccae3e9..665954b 100644 --- a/tox.ini +++ b/tox.ini @@ -7,7 +7,7 @@ python = 3.7: py37 3.8: py38 3.9: py39 - + [gh-actions:env] PLATFORM = ubuntu-latest: linux @@ -15,17 +15,17 @@ PLATFORM = windows-latest: windows [testenv] -platform = +platform = macos: darwin linux: linux windows: win32 -passenv = +passenv = CI GITHUB_ACTIONS DISPLAY XAUTHORITY NUMPY_EXPERIMENTAL_ARRAY_FUNCTION PYVISTA_OFF_SCREEN -deps = +deps = pytest # https://docs.pytest.org/en/latest/contents.html pytest-cov # https://pytest-cov.readthedocs.io/en/latest/ pytest-xvfb ; sys_platform == 'linux' From e46c07b5d34d5bb62ad36c278029f6a864e5fd0a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 14 Apr 2022 10:10:28 +0000 Subject: [PATCH 4/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- napari_ome_zarr/_reader.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/napari_ome_zarr/_reader.py b/napari_ome_zarr/_reader.py index 91986fe..137319c 100644 --- a/napari_ome_zarr/_reader.py +++ b/napari_ome_zarr/_reader.py @@ -9,7 +9,6 @@ from typing import Any, Callable, Dict, Iterator, List, Optional import numpy as np - from ome_zarr.io import parse_url from ome_zarr.reader import Label, Node, Reader from ome_zarr.types import LayerData, PathLike, ReaderFunction @@ -139,7 +138,9 @@ def f(*args: Any, **kwargs: Any) -> List[LayerData]: if x in node.metadata: metadata[x] = node.metadata[x] if channel_axis is not None: - data = [np.squeeze(level, axis=channel_axis) for level in node.data] + data = [ + np.squeeze(level, axis=channel_axis) for level in node.data + ] else: # Handle the removal of vispy requirement from ome-zarr-py cms = node.metadata.get("colormap", []) From 2b171d75984f8ea12655c1afa6c19f25fa27aeff Mon Sep 17 00:00:00 2001 From: jmoore Date: Thu, 14 Apr 2022 12:31:12 +0200 Subject: [PATCH 5/5] Follow-up linting --- napari_ome_zarr/_reader.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/napari_ome_zarr/_reader.py b/napari_ome_zarr/_reader.py index 137319c..1107f2b 100644 --- a/napari_ome_zarr/_reader.py +++ b/napari_ome_zarr/_reader.py @@ -87,7 +87,9 @@ def transform_properties( return properties -def transform_scale(node_metadata, metadata, channel_axis): +def transform_scale( + node_metadata: Dict, metadata: Dict, channel_axis: Optional[int] +) -> None: """ e.g. transformation is {"scale": [0.2, 0.06, 0.06]} Get a list of these for each level in data. Just use first? @@ -126,7 +128,7 @@ def f(*args: Any, **kwargs: Any) -> List[LayerData]: ch_types = [axis["type"] for axis in node.metadata["axes"]] if "channel" in ch_types: channel_axis = ch_types.index("channel") - except: + except Exception: LOGGER.error("Error reading axes: Please update ome-zarr") raise