diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ca128ae..6fab62e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,26 +2,29 @@ fail_fast: false default_language_version: python: python3 default_stages: - - commit - - push + - pre-commit + - pre-push minimum_pre_commit_version: 2.16.0 repos: - repo: https://github.com/pre-commit/mirrors-prettier rev: v4.0.0-alpha.8 hooks: - id: prettier + - repo: https://github.com/tox-dev/pyproject-fmt rev: "2.2.4" hooks: - id: pyproject-fmt + - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.9.2 hooks: - id: ruff types_or: [python, pyi, jupyter] - args: [--fix, --exit-non-zero-on-fix] + args: [--fix, --exit-non-zero-on-fix, --unsafe-fixes] - id: ruff-format types_or: [python, pyi, jupyter] + - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.6.0 hooks: @@ -32,22 +35,25 @@ repos: args: [--fix=lf] - id: trailing-whitespace - id: check-case-conflict - # Check that there are no merge conflicts (could be generated by template sync) - id: check-merge-conflict args: [--assume-in-merge] + - repo: local hooks: - id: forbid-to-commit - name: Don't commit rej files + name: Don't commit .rej files entry: | Cannot commit .rej files. These indicate merge conflicts that arise during automated template updates. Fix the merge conflicts manually and remove the .rej files. language: fail files: '.*\.rej$' - - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.14.1 - hooks: - - id: mypy - args: [--no-strict-optional, --ignore-missing-imports] - additional_dependencies: - ["types-setuptools", "types-requests", "types-attrs"] + + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.14.1 + hooks: + - id: mypy + args: [--no-strict-optional, --ignore-missing-imports] + additional_dependencies: + - types-setuptools + - types-requests + - types-attrs diff --git a/src/spatialdata_db/lamin_spatialdatadb_curator.py b/src/spatialdata_db/lamin_spatialdatadb_curator.py index ad7b29a..a9240a1 100644 --- a/src/spatialdata_db/lamin_spatialdatadb_curator.py +++ b/src/spatialdata_db/lamin_spatialdatadb_curator.py @@ -1,20 +1,18 @@ -from lamindb.curators import SpatialDataCurator -from spatialdata import SpatialData import bionty as bt import lamindb as ln +from lamindb.base.types import FieldAttr +from lamindb.curators._spatial import SpatialDataCurator +from lamindb.models import Record +from spatialdata import SpatialData -from lnschema_core import Record -from lnschema_core.types import FieldAttr -from lnschema_core import ( - Record, -) class SpatialDataDBCurator(SpatialDataCurator): + """Custom Curator for SpatialDataDB""" DEFAULT_CATEGORICALS = { "assay": bt.ExperimentalFactor.name, "chemistry_version": ln.ULabel.name, - 'organism': bt.Organism.name, + "organism": bt.Organism.name, "tissue": bt.Tissue.name, "disease": bt.Disease.name, "license": ln.ULabel.name, @@ -29,11 +27,11 @@ class SpatialDataDBCurator(SpatialDataCurator): "preproc_version": "unknown", } - FIXED_SOURCES = { - # TODO: fix ontologies - } + FIXED_SOURCES = { # type: ignore + # TODO: fix ontologies + } - DEFAULT_VAR_INDEX = {'table': bt.Gene.ensembl_gene_id} + DEFAULT_VAR_INDEX = {"table": bt.Gene.ensembl_gene_id} def __init__( self, @@ -49,9 +47,7 @@ def __init__( sample_metadata_key: str = "sample", ): if categoricals is None: - categoricals = dict([( - sample_metadata_key, self.DEFAULT_CATEGORICALS - )]) + categoricals = {sample_metadata_key: self.DEFAULT_CATEGORICALS} super().__init__( sdata, @@ -63,4 +59,4 @@ def __init__( sources=sources, exclude=exclude, sample_metadata_key=sample_metadata_key, - ) \ No newline at end of file + )