From 2f77b9fcbdb52e2e7601bfb618e8fab4d461a9d0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 17 Jan 2025 18:09:25 +1100 Subject: [PATCH] ci: [pre-commit.ci] autoupdate (#360) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v4.6.0 → v5.0.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.6.0...v5.0.0) - [github.com/psf/black: 24.8.0 → 24.10.0](https://github.com/psf/black/compare/24.8.0...24.10.0) - [github.com/astral-sh/ruff-pre-commit: v0.6.4 → v0.8.6](https://github.com/astral-sh/ruff-pre-commit/compare/v0.6.4...v0.8.6) - [github.com/pre-commit/mirrors-mypy: v1.11.2 → v1.14.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.11.2...v1.14.1) --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Draga Doncila Pop <17995243+DragaDoncila@users.noreply.github.com> Co-authored-by: Draga Doncila --- .pre-commit-config.yaml | 8 ++++---- src/npe2/__init__.py | 10 +++++----- src/npe2/_inspection/__init__.py | 4 ++-- src/npe2/_inspection/_fetch.py | 2 +- src/npe2/_plugin_manager.py | 15 ++++----------- src/npe2/_pydantic_compat.py | 14 +++++++------- src/npe2/implements.pyi | 2 +- src/npe2/manifest/__init__.py | 2 +- src/npe2/manifest/contributions/_contributions.py | 6 +++--- src/npe2/manifest/contributions/_json_schema.py | 11 +++++------ 10 files changed, 33 insertions(+), 41 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 92889788..7878b23e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,24 +7,24 @@ exclude: _docs/example_plugin/some_module.py repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: check-docstring-first - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/psf/black - rev: 24.8.0 + rev: 24.10.0 hooks: - id: black - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.6.4 + rev: v0.8.6 hooks: - id: ruff - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.11.2 + rev: v1.14.1 hooks: - id: mypy additional_dependencies: diff --git a/src/npe2/__init__.py b/src/npe2/__init__.py index e55a87c2..c5544b16 100644 --- a/src/npe2/__init__.py +++ b/src/npe2/__init__.py @@ -15,16 +15,16 @@ from .manifest import PackageMetadata, PluginManifest __all__ = [ - "__version__", "DynamicPlugin", - "fetch_manifest", - "get_manifest_from_wheel", "PackageMetadata", "PluginContext", "PluginManager", "PluginManifest", - "read_get_reader", + "__version__", + "fetch_manifest", + "get_manifest_from_wheel", "read", - "write_get_writer", + "read_get_reader", "write", + "write_get_writer", ] diff --git a/src/npe2/_inspection/__init__.py b/src/npe2/_inspection/__init__.py index 63a818f0..04becbf1 100644 --- a/src/npe2/_inspection/__init__.py +++ b/src/npe2/_inspection/__init__.py @@ -7,7 +7,7 @@ __all__ = [ "NPE2PluginModuleVisitor", - "find_npe2_module_contributions", - "find_npe1_module_contributions", "compile", + "find_npe1_module_contributions", + "find_npe2_module_contributions", ] diff --git a/src/npe2/_inspection/_fetch.py b/src/npe2/_inspection/_fetch.py index 3335d0dd..4e00ac59 100644 --- a/src/npe2/_inspection/_fetch.py +++ b/src/npe2/_inspection/_fetch.py @@ -36,8 +36,8 @@ NPE2_ENTRY_POINT = "napari.manifest" __all__ = [ "fetch_manifest", - "get_pypi_url", "get_hub_plugin", + "get_pypi_url", ] diff --git a/src/npe2/_plugin_manager.py b/src/npe2/_plugin_manager.py index 4f960c30..f05b8b7a 100644 --- a/src/npe2/_plugin_manager.py +++ b/src/npe2/_plugin_manager.py @@ -248,11 +248,8 @@ def __init__( pass else: # pragma: no cover vsplit = nv.split(".")[:4] - if ( - "dev" in nv - and vsplit < ["0", "4", "16", "dev4"] - or "dev" not in nv - and vsplit < ["0", "4", "16"] + if ("dev" in nv and vsplit < ["0", "4", "16", "dev4"]) or ( + "dev" not in nv and vsplit < ["0", "4", "16"] ): self.discover() @@ -698,12 +695,8 @@ def get_writer( for writer in self.iter_compatible_writers(layer_types): if not plugin_name or writer.command.startswith(plugin_name): - if ( - ext - and ext in writer.filename_extensions - or not ext - and len(layer_types) != 1 - and not writer.filename_extensions + if (ext and ext in writer.filename_extensions) or ( + not ext and len(layer_types) != 1 and not writer.filename_extensions ): return writer, path elif not ext and len(layer_types) == 1: # No extension, single layer. diff --git a/src/npe2/_pydantic_compat.py b/src/npe2/_pydantic_compat.py index 1e093cf1..3bc75122 100644 --- a/src/npe2/_pydantic_compat.py +++ b/src/npe2/_pydantic_compat.py @@ -37,18 +37,18 @@ __all__ = ( + "SHAPE_LIST", "BaseModel", + "ErrorWrapper", "Extra", "Field", - "ValidationError", - "root_validator", - "validator", + "GenericModel", + "ModelMetaclass", "PrivateAttr", + "ValidationError", "color", "conlist", "constr", - "ModelMetaclass", - "ErrorWrapper", - "GenericModel", - "SHAPE_LIST", + "root_validator", + "validator", ) diff --git a/src/npe2/implements.pyi b/src/npe2/implements.pyi index 54d04a3f..2c0c0965 100644 --- a/src/npe2/implements.pyi +++ b/src/npe2/implements.pyi @@ -24,7 +24,7 @@ def writer( id: str, title: str, layer_types: list[str], - filename_extensions: list[str] = [], # noqa: B006 + filename_extensions: list[str] = [], display_name: str = "", ensure_args_valid: bool = False, ) -> Callable[[T], T]: diff --git a/src/npe2/manifest/__init__.py b/src/npe2/manifest/__init__.py index 1c1b7df7..687f4b1f 100644 --- a/src/npe2/manifest/__init__.py +++ b/src/npe2/manifest/__init__.py @@ -1,4 +1,4 @@ from ._package_metadata import PackageMetadata from .schema import ENTRY_POINT, PluginManifest -__all__ = ["PackageMetadata", "PluginManifest", "ENTRY_POINT"] +__all__ = ["ENTRY_POINT", "PackageMetadata", "PluginManifest"] diff --git a/src/npe2/manifest/contributions/_contributions.py b/src/npe2/manifest/contributions/_contributions.py index fc956925..8ab9af6f 100644 --- a/src/npe2/manifest/contributions/_contributions.py +++ b/src/npe2/manifest/contributions/_contributions.py @@ -14,18 +14,18 @@ from ._writers import WriterContribution __all__ = [ - "ContributionPoints", "CommandContribution", + "ContributionPoints", "KeyBindingContribution", "MenuItem", "ReaderContribution", "SampleDataContribution", + "SampleDataGenerator", + "SampleDataURI", "SubmenuContribution", "ThemeContribution", "WidgetContribution", "WriterContribution", - "SampleDataGenerator", - "SampleDataURI", ] diff --git a/src/npe2/manifest/contributions/_json_schema.py b/src/npe2/manifest/contributions/_json_schema.py index 2d8f7071..3c637744 100644 --- a/src/npe2/manifest/contributions/_json_schema.py +++ b/src/npe2/manifest/contributions/_json_schema.py @@ -21,10 +21,10 @@ ValidationError = Exception __all__ = [ - "ValidationError", "Draft04JsonSchema", "Draft06JsonSchema", "Draft07JsonSchema", + "ValidationError", ] JsonType = Literal["array", "boolean", "integer", "null", "number", "object", "string"] @@ -169,14 +169,13 @@ def is_array(self) -> bool: @property def is_object(self) -> bool: """Return True if this schema is an object schema.""" - return ( - self.properties is not None - or self.type == "object" + return self.properties is not None or ( + self.type == "object" and not self.all_of and not self.one_of and not self.any_of - and not getattr(self, "ref", False) # draft 6+ - ) + and not getattr(self, "ref", False) + ) # draft 6+ @property def json_validator(self) -> Type[Validator]: