Skip to content

Commit

Permalink
handle pyright warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jsstevenson committed May 24, 2024
1 parent 37c7dfe commit 278fcad
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/biocommons/seqrepo/seqaliasdb/seqaliasdb.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import sqlite3
from importlib import resources

import pkg_resources
import yoyo

from .._internal.translate import translate_alias_records, translate_api2db
Expand Down Expand Up @@ -32,7 +32,6 @@ def __init__(
check_same_thread=True,
):
self._db_path = db_path
self._db = None
self._writeable = writeable

if translate_ncbi_namespace is not None:
Expand Down Expand Up @@ -234,10 +233,16 @@ def _upgrade_db(self):
sqlite3.connect(self._db_path).close() # ensure that it exists
db_url = "sqlite:///" + self._db_path
backend = yoyo.get_backend(db_url)
migration_dir = pkg_resources.resource_filename(__package__, migration_path)
if __package__ is None:
msg = (
"__package__ is None. This module must be part of a package to "
"resolve the migration files path."
)
raise ImportError(msg)
migration_dir = str(resources.files(__package__) / migration_path)
migrations = yoyo.read_migrations(migration_dir)
assert len(migrations) > 0, (
"no migration scripts found -- wrong migraion path for " + __package__
)
assert (
len(migrations) > 0
), f"no migration scripts found -- wrong migraion path for {__package__}"
migrations_to_apply = backend.to_apply(migrations)
backend.apply_migrations(migrations_to_apply)

0 comments on commit 278fcad

Please sign in to comment.