Skip to content

Commit

Permalink
ci: [pre-commit.ci] autoupdate (#306)
Browse files Browse the repository at this point in the history
<!--pre-commit.ci start-->
updates:
- [github.com/psf/black: 23.3.0 →
23.7.0](psf/black@23.3.0...23.7.0)
- [github.com/astral-sh/ruff-pre-commit: v0.0.276 →
v0.0.282](astral-sh/ruff-pre-commit@v0.0.276...v0.0.282)
<!--pre-commit.ci end-->

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
pre-commit-ci[bot] authored Aug 9, 2023
1 parent 789a127 commit 80ca5fe
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 21 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/psf/black
rev: 23.3.0
rev: 23.7.0
hooks:
- id: black

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.276
rev: v0.0.282
hooks:
- id: ruff

Expand Down
8 changes: 4 additions & 4 deletions src/npe2/implements.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Callable, List, TypeVar
from typing import Any, Callable, TypeVar

from pydantic import BaseModel as BaseModel

Expand All @@ -13,7 +13,7 @@ def reader(
*,
id: str,
title: str,
filename_patterns: List[str],
filename_patterns: list[str],
accepts_directories: bool = False,
ensure_args_valid: bool = False,
) -> Callable[[T], T]:
Expand All @@ -23,8 +23,8 @@ def writer(
*,
id: str,
title: str,
layer_types: List[str],
filename_extensions: List[str] = [], # noqa: B006
layer_types: list[str],
filename_extensions: list[str] = [], # noqa: B006
display_name: str = "",
ensure_args_valid: bool = False,
) -> Callable[[T], T]:
Expand Down
10 changes: 5 additions & 5 deletions tests/test_contributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ def test_writer_valid_layer_type_expressions(expr, uses_sample_plugin):
def test_basic_iter_reader(uses_sample_plugin, plugin_manager: PluginManager, tmp_path):
tmp_path = str(tmp_path)
assert not list(plugin_manager.iter_compatible_readers(""))
reader = list(plugin_manager.iter_compatible_readers(tmp_path))[0]
reader = next(iter(plugin_manager.iter_compatible_readers(tmp_path)))
assert reader.command == f"{SAMPLE_PLUGIN_NAME}.some_reader"

reader = list(plugin_manager.iter_compatible_readers([tmp_path, tmp_path]))[0]
reader = next(iter(plugin_manager.iter_compatible_readers([tmp_path, tmp_path])))
assert reader.command == f"{SAMPLE_PLUGIN_NAME}.some_reader"

with pytest.raises(ValueError):
Expand All @@ -108,7 +108,7 @@ def test_widgets(uses_sample_plugin, plugin_manager: PluginManager):


def test_sample(uses_sample_plugin, plugin_manager: PluginManager):
plugin, contribs = list(plugin_manager.iter_sample_data())[0]
plugin, contribs = next(iter(plugin_manager.iter_sample_data()))
assert plugin == SAMPLE_PLUGIN_NAME
assert len(contribs) == 2
ctrbA, ctrbB = contribs
Expand All @@ -125,12 +125,12 @@ def test_sample(uses_sample_plugin, plugin_manager: PluginManager):


def test_directory_reader(uses_sample_plugin, plugin_manager: PluginManager, tmp_path):
reader = list(plugin_manager.iter_compatible_readers(str(tmp_path)))[0]
reader = next(iter(plugin_manager.iter_compatible_readers(str(tmp_path))))
assert reader.command == f"{SAMPLE_PLUGIN_NAME}.some_reader"


def test_themes(uses_sample_plugin, plugin_manager: PluginManager):
theme = list(plugin_manager.iter_themes())[0]
theme = next(iter(plugin_manager.iter_themes()))
assert theme.label == "SampleTheme"


Expand Down
6 changes: 3 additions & 3 deletions tests/test_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_discover(uses_sample_plugin):
[(manifest, distribution, error)] = discover_results
assert manifest and manifest.name == SAMPLE_PLUGIN_NAME
assert distribution
entrypoint = tuple(distribution.entry_points)[0]
entrypoint = next(iter(distribution.entry_points))
assert entrypoint and entrypoint.group == "napari.manifest" == ENTRY_POINT
assert entrypoint.value == f"{SAMPLE_MODULE_NAME}:napari.yaml"
assert error is None
Expand Down Expand Up @@ -82,12 +82,12 @@ def test_discover_errors(tmp_path: Path):
res_a, res_b = discover_results
assert res_a.manifest is None
assert res_a.distribution
assert tuple(res_a.distribution.entry_points)[0].value == bad_value
assert next(iter(res_a.distribution.entry_points)).value == bad_value
assert "Cannot find module 'asdfsad'" in str(res_a.error)

assert res_b.manifest is None
assert res_b.distribution
assert tuple(res_b.distribution.entry_points)[0].value == "module:napari.yaml"
assert next(iter(res_b.distribution.entry_points)).value == "module:napari.yaml"
assert isinstance(res_b.error, ValidationError)


Expand Down
10 changes: 4 additions & 6 deletions tests/test_setuptools_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,14 @@
ROOT = Path(__file__).parent.parent

TEMPLATE = Path("my_module") / "_napari.yaml"
PYPROJECT = """
PYPROJECT = f"""
[build-system]
requires = ["setuptools", "wheel", "npe2 @ file://{}"]
requires = ["setuptools", "wheel", "npe2 @ file://{ROOT}"]
build-backend = "setuptools.build_meta"
[tool.npe2]
template="{}"
""".format(
ROOT, TEMPLATE
)
template="{TEMPLATE}"
"""


@pytest.mark.skipif(not os.getenv("CI"), reason="slow, only run on CI")
Expand Down
2 changes: 1 addition & 1 deletion tests/test_validations.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def _valid_mutator_no_contributions_None(data):
def test_valid_mutations(mutator, uses_sample_plugin):
assert mutator.__name__.startswith("_valid")

pm = list(PluginManifest.discover())[0]
pm = next(iter(PluginManifest.discover()))
assert pm.manifest
# make sure the data is a copy as we'll mutate it
data = json.loads(pm.manifest.json(exclude_unset=True))
Expand Down

0 comments on commit 80ca5fe

Please sign in to comment.