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 cba09d27..03bb1173 100644 --- a/src/npe2/_inspection/_fetch.py +++ b/src/npe2/_inspection/_fetch.py @@ -39,9 +39,9 @@ NPE2_ENTRY_POINT = "napari.manifest" __all__ = [ "fetch_manifest", - "get_pypi_url", "get_hub_plugin", "get_pypi_plugins", + "get_pypi_url", ] diff --git a/src/npe2/_plugin_manager.py b/src/npe2/_plugin_manager.py index cec0664b..8a3c113a 100644 --- a/src/npe2/_plugin_manager.py +++ b/src/npe2/_plugin_manager.py @@ -249,10 +249,10 @@ def __init__( 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"] + ("dev" in nv + and vsplit < ["0", "4", "16", "dev4"]) + or ("dev" not in nv + and vsplit < ["0", "4", "16"]) ): self.discover() @@ -699,11 +699,11 @@ 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 + (ext + and ext in writer.filename_extensions) + or (not ext and len(layer_types) != 1 - and not writer.filename_extensions + 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..d02607e2 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"] @@ -171,11 +171,11 @@ def is_object(self) -> bool: """Return True if this schema is an object schema.""" return ( self.properties is not None - or self.type == "object" + 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