diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1e54869b..5128f2f5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,18 +9,18 @@ ci: skip: [] repos: - repo: https://github.com/rbubley/mirrors-prettier - rev: v3.5.3 + rev: v3.7.4 hooks: - id: prettier exclude: ^.github/workflows/test.yaml - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.15.0 + rev: v1.19.1 hooks: - id: mypy additional_dependencies: [numpy, types-requests] exclude: tests/|docs/ - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.11.11 + rev: v0.14.10 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] diff --git a/src/spatialdata/_core/query/relational_query.py b/src/spatialdata/_core/query/relational_query.py index 247bffeb..3f0fa935 100644 --- a/src/spatialdata/_core/query/relational_query.py +++ b/src/spatialdata/_core/query/relational_query.py @@ -968,6 +968,7 @@ def get_values( assert obs[region_key].nunique() == 1 assert obs[instance_key].nunique() == len(matched_table) else: + assert isinstance(element, AnnData) matched_table = element instance_key = matched_table.uns[TableModel.ATTRS_KEY][TableModel.INSTANCE_KEY] region_key = matched_table.uns[TableModel.ATTRS_KEY][TableModel.REGION_KEY_KEY] diff --git a/src/spatialdata/_core/spatialdata.py b/src/spatialdata/_core/spatialdata.py index 21bd6c5b..abc5e6ec 100644 --- a/src/spatialdata/_core/spatialdata.py +++ b/src/spatialdata/_core/spatialdata.py @@ -702,7 +702,7 @@ def _filter_tables( assert element_names is not None table = _filter_table_by_element_names(table, element_names) - if len(table) != 0: + if table is not None and len(table) != 0: tables[table_name] = table elif by == "elements": from spatialdata._core.query.relational_query import ( @@ -711,7 +711,7 @@ def _filter_tables( assert elements_dict is not None table = _filter_table_by_elements(table, elements_dict=elements_dict) - if len(table) != 0: + if table is not None and len(table) != 0: tables[table_name] = table else: tables = self.tables diff --git a/src/spatialdata/_io/io_zarr.py b/src/spatialdata/_io/io_zarr.py index 98919d61..0312dc96 100644 --- a/src/spatialdata/_io/io_zarr.py +++ b/src/spatialdata/_io/io_zarr.py @@ -158,7 +158,7 @@ def read_zarr( # the following is the SpatialDataContainerFormat version if "spatialdata_attrs" not in root_group.metadata.attributes: # backward compatibility for pre-versioned SpatialData zarr stores - sdata_version = cast(Literal["0.1", "0.2"], "0.1") + sdata_version: Literal["0.1", "0.2"] = "0.1" else: sdata_version = root_group.metadata.attributes["spatialdata_attrs"]["version"] if sdata_version == "0.1":