Skip to content

Commit dd12c25

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

6 files changed

Lines changed: 22 additions & 26 deletions

File tree

‎setup.cfg‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ long_description_content_type = text/markdown; charset=UTF-8; variant=GFM
1515
url = https://github.com/biocpy/txdb
1616
# Add here related links, for example:
1717
project_urls =
18-
Documentation = https://biocpy.github.io/txdb/
18+
Documentation = https://biocpy.github.io/txdb/
1919
Source = https://github.com/biocpy/txdb
2020
# Changelog = https://pyscaffold.org/en/latest/changelog.html
2121
# Tracker = https://github.com/pyscaffold/pyscaffold/issues

‎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/txdb/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@
1919
from .txdb import TxDb
2020
from .txdbregistry import TxDbRegistry
2121

22-
__all__ = ["TxDb", "TxDbRegistry", "TxDbRecord"]
22+
__all__ = ["TxDb", "TxDbRecord", "TxDbRegistry"]

‎src/txdb/record.py‎

Lines changed: 10 additions & 13 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"
@@ -14,18 +13,18 @@ class TxDbRecord:
1413
"""Container for a single TxDb entry."""
1514

1615
txdb_id: str
17-
release_date: Optional[date]
16+
release_date: date | None
1817
url: str
1918

20-
organism: Optional[str] = None # e.g. "Hsapiens"
21-
source: Optional[str] = None # e.g. "UCSC", "BioMart"
22-
build: Optional[str] = None # e.g. "hg38.knownGene"
19+
organism: str | None = None # e.g. "Hsapiens"
20+
source: str | None = None # e.g. "UCSC", "BioMart"
21+
build: str | None = None # e.g. "hg38.knownGene"
2322

2423
# Parsed from URL path (e.g. .../3.22/TxDb...)
25-
bioc_version: Optional[str] = None
24+
bioc_version: str | None = None
2625

2726
@classmethod
28-
def from_config_entry(cls, txdb_id: str, entry: dict) -> "TxDbRecord":
27+
def from_config_entry(cls, txdb_id: str, entry: dict) -> TxDbRecord:
2928
"""Build a record from a TXDB_CONFIG entry:
3029
{
3130
"release_date": "YYYY-MM-DD", # optional
@@ -35,7 +34,7 @@ def from_config_entry(cls, txdb_id: str, entry: dict) -> "TxDbRecord":
3534
url = entry["url"]
3635

3736
date_str = entry.get("release_date")
38-
rel_date: Optional[date]
37+
rel_date: date | None
3938
if date_str:
4039
rel_date = datetime.strptime(date_str, "%Y-%m-%d").date()
4140
else:
@@ -62,10 +61,8 @@ def _parse_txdb_id(txdb_id: str):
6261
into (organism, source, build).
6362
"""
6463
name = txdb_id
65-
if name.startswith("TxDb."):
66-
name = name[len("TxDb.") :]
67-
if name.endswith(".sqlite"):
68-
name = name[: -len(".sqlite")]
64+
name = name.removeprefix("TxDb.")
65+
name = name.removesuffix(".sqlite")
6966

7067
parts = name.split(".")
7168
if len(parts) < 2:
@@ -77,7 +74,7 @@ def _parse_txdb_id(txdb_id: str):
7774
return organism, source, build
7875

7976

80-
def _parse_bioc_version(url: str) -> Optional[str]:
77+
def _parse_bioc_version(url: str) -> str | None:
8178
"""Extract the Bioconductor/AnnotationHub-like version from URL.
8279
8380
Example:

‎src/txdb/txdb.py‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import sqlite3
2-
from typing import List, Optional
32

43
from biocframe import BiocFrame
54
from genomicranges import GenomicRanges, SeqInfo
@@ -95,8 +94,8 @@ def _fetch_as_gr(
9594
self,
9695
table: str,
9796
prefix: str,
98-
columns: Optional[List[str]] = None,
99-
filter: Optional[dict] = None,
97+
columns: list[str] | None = None,
98+
filter: dict | None = None,
10099
) -> GenomicRanges:
101100
"""Internal helper to fetch a table and convert to GenomicRanges.
102101
@@ -165,7 +164,7 @@ def _fetch_as_gr(
165164
seqinfo=self.seqinfo,
166165
)
167166

168-
def transcripts(self, filter: Optional[dict] = None) -> GenomicRanges:
167+
def transcripts(self, filter: dict | None = None) -> GenomicRanges:
169168
"""Retrieve transcripts as a GenomicRanges object.
170169
171170
Args:
@@ -177,7 +176,7 @@ def transcripts(self, filter: Optional[dict] = None) -> GenomicRanges:
177176
"""
178177
return self._fetch_as_gr("transcript", "tx", filter=filter)
179178

180-
def exons(self, filter: Optional[dict] = None) -> GenomicRanges:
179+
def exons(self, filter: dict | None = None) -> GenomicRanges:
181180
"""Retrieve exons as a GenomicRanges object.
182181
183182
Args:
@@ -189,7 +188,7 @@ def exons(self, filter: Optional[dict] = None) -> GenomicRanges:
189188
"""
190189
return self._fetch_as_gr("exon", "exon", filter=filter)
191190

192-
def cds(self, filter: Optional[dict] = None) -> GenomicRanges:
191+
def cds(self, filter: dict | None = None) -> GenomicRanges:
193192
"""Retrieve coding sequences (CDS) as a GenomicRanges object.
194193
195194
Args:

‎src/txdb/txdbregistry.py‎

Lines changed: 4 additions & 4 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, Optional, Union
4+
from typing import Any
55

66
from pybiocfilecache import BiocFileCache
77

@@ -19,7 +19,7 @@ class TxDbRegistry:
1919

2020
def __init__(
2121
self,
22-
cache_dir: Optional[Union[str, Path]] = None,
22+
cache_dir: str | Path | None = None,
2323
force: bool = False,
2424
) -> None:
2525
"""Initialize the TxDB registry.
@@ -39,7 +39,7 @@ def __init__(
3939
self._cache_dir.mkdir(parents=True, exist_ok=True)
4040
self._bfc = BiocFileCache(self._cache_dir)
4141

42-
self._registry_map: Dict[str, TxDbRecord] = {}
42+
self._registry_map: dict[str, TxDbRecord] = {}
4343

4444
self._initialize_registry(force=force)
4545

@@ -195,7 +195,7 @@ def load_db(self, txdb_id: str, force: bool = False) -> TxDb:
195195
path = self.download(txdb_id, force=force)
196196
return TxDb(path)
197197

198-
def _get_filepath(self, resource: Any) -> Optional[str]:
198+
def _get_filepath(self, resource: Any) -> str | None:
199199
"""Helper to extract absolute path from a BiocFileCache resource."""
200200
if hasattr(resource, "rpath"):
201201
rel_path = str(resource.rpath)

0 commit comments

Comments
 (0)