Skip to content

Commit 10490b1

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 6ac726e commit 10490b1

4 files changed

Lines changed: 16 additions & 18 deletions

File tree

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
if __name__ == "__main__":
1313
try:
1414
setup(use_scm_version={"version_scheme": "no-guess-dev"})
15-
except: # noqa
15+
except:
1616
print(
1717
"\n\nAn error occurred while building the project, "
1818
"please ensure you have the most updated version of setuptools, "

src/experimenthub/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
finally:
1616
del version, PackageNotFoundError
1717

18-
from .registry import ExperimentHubRegistry
1918
from .record import ExperimentHubRecord
19+
from .registry import ExperimentHubRegistry

src/experimenthub/record.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from dataclasses import dataclass
44
from datetime import date, datetime
5-
from typing import Optional
65

76
__author__ = "Jayaram Kancherla"
87
__copyright__ = "Jayaram Kancherla"
@@ -15,16 +14,16 @@ class ExperimentHubRecord:
1514

1615
ehub_id: str
1716
title: str
18-
species: Optional[str]
19-
taxonomy_id: Optional[str]
20-
genome: Optional[str]
21-
description: Optional[str]
17+
species: str | None
18+
taxonomy_id: str | None
19+
genome: str | None
20+
description: str | None
2221
url: str
23-
release_date: Optional[date]
24-
preparer_dataclass: Optional[str]
22+
release_date: date | None
23+
preparer_dataclass: str | None
2524

2625
@classmethod
27-
def from_db_row(cls, row: tuple) -> "ExperimentHubRecord":
26+
def from_db_row(cls, row: tuple) -> ExperimentHubRecord:
2827
"""Build a record from a database query row.
2928
3029
Expected row format:
@@ -33,7 +32,7 @@ def from_db_row(cls, row: tuple) -> "ExperimentHubRecord":
3332
rid, title, species, tax_id, genome, desc, url, date_str, rdataclass = row
3433
ehub_id = f"EH{rid}"
3534

36-
rel_date: Optional[date] = None
35+
rel_date: date | None = None
3736
if date_str:
3837
try:
3938
rel_date = datetime.strptime(str(date_str).split(" ")[0], "%Y-%m-%d").date()

src/experimenthub/registry.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22
import sqlite3
33
from pathlib import Path
4-
from typing import Any, Dict, List, Optional, Union
4+
from typing import Any
55

66
from pybiocfilecache import BiocFileCache
77

@@ -24,7 +24,6 @@ class ExperimentHubRegistry:
2424
"matrix",
2525
"numeric",
2626
"int",
27-
"matrix",
2827
"dataframe",
2928
"data.frame",
3029
"data frame",
@@ -42,7 +41,7 @@ class ExperimentHubRegistry:
4241

4342
def __init__(
4443
self,
45-
cache_dir: Optional[Union[str, Path]] = None,
44+
cache_dir: str | Path | None = None,
4645
force: bool = False,
4746
) -> None:
4847
"""Initialize the ExperimentHub registry.
@@ -62,7 +61,7 @@ def __init__(
6261
self._cache_dir.mkdir(parents=True, exist_ok=True)
6362
self._bfc = BiocFileCache(self._cache_dir)
6463

65-
self._registry_map: Dict[str, ExperimentHubRecord] = {}
64+
self._registry_map: dict[str, ExperimentHubRecord] = {}
6665

6766
self._initialize_registry(force=force)
6867

@@ -135,7 +134,7 @@ def _initialize_registry(self, force: bool = False):
135134
record = ExperimentHubRecord.from_db_row(row)
136135
self._registry_map[record.ehub_id] = record
137136

138-
def list_ids(self) -> List[str]:
137+
def list_ids(self) -> list[str]:
139138
"""List all available ExperimentHub IDs (e.g., 'EH1', 'EH123')."""
140139
return sorted(list(self._registry_map.keys()), key=lambda x: int(x[2:]))
141140

@@ -146,7 +145,7 @@ def get_record(self, ehub_id: str) -> ExperimentHubRecord:
146145

147146
return self._registry_map[ehub_id]
148147

149-
def search(self, query: str) -> List[ExperimentHubRecord]:
148+
def search(self, query: str) -> list[ExperimentHubRecord]:
150149
"""Search for resources matching the query string."""
151150
q = query.lower()
152151
results = []
@@ -220,7 +219,7 @@ def load(self, ehub_id: str, force: bool = False) -> Any:
220219
except Exception as e:
221220
raise RuntimeError(f"Failed to load R data from {path}: {e}")
222221

223-
def _get_filepath(self, resource: Any) -> Optional[str]:
222+
def _get_filepath(self, resource: Any) -> str | None:
224223
"""Helper to extract absolute path from a BiocFileCache resource."""
225224
if hasattr(resource, "rpath"):
226225
rel_path = str(resource.rpath)

0 commit comments

Comments
 (0)