Skip to content

Commit

Permalink
Use DeclarativeBase as base class
Browse files Browse the repository at this point in the history
mypy bug workaround no longer needed as we are no longer specifying a metaclass
  • Loading branch information
jdavcs committed Apr 3, 2024
1 parent d8756c6 commit c63f037
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions lib/galaxy/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
from sqlalchemy.orm import (
aliased,
column_property,
DeclarativeBase,
deferred,
joinedload,
Mapped,
Expand All @@ -119,6 +120,7 @@
from sqlalchemy.orm.attributes import flag_modified
from sqlalchemy.orm.collections import attribute_keyed_dict
from sqlalchemy.sql import exists
from sqlalchemy.sql.expression import FromClause
from typing_extensions import (
Literal,
Protocol,
Expand Down Expand Up @@ -224,23 +226,15 @@


if TYPE_CHECKING:
# Workaround for https://github.com/python/mypy/issues/14182
from sqlalchemy.orm import DeclarativeMeta as _DeclarativeMeta

class DeclarativeMeta(_DeclarativeMeta, type):
pass

from galaxy.datatypes.data import Data
from galaxy.tools import DefaultToolState
from galaxy.workflow.modules import WorkflowModule

class _HasTable:
table: Table
__table__: Table
table: FromClause
__table__: FromClause

else:
from sqlalchemy.orm import DeclarativeMeta

_HasTable = object


Expand All @@ -252,7 +246,7 @@ def get_uuid(uuid: Optional[Union[UUID, str]] = None) -> UUID:
return UUID(str(uuid))


class Base(_HasTable, metaclass=DeclarativeMeta):
class Base(_HasTable, DeclarativeBase):
__abstract__ = True
metadata = MetaData(naming_convention=NAMING_CONVENTION)
mapper_registry.metadata = metadata
Expand Down

0 comments on commit c63f037

Please sign in to comment.