diff --git a/bot/data/adapted.py b/bot/data/adapted.py index b5c3e7a7..12bebd4e 100644 --- a/bot/data/adapted.py +++ b/bot/data/adapted.py @@ -20,7 +20,10 @@ class RegisterEnum(Attachable): return self async def on_init(self, registry: Registry): - connection = await registry._conn.get_connection() + connector = registry._conn + if connector is None: + raise ValueError("Cannot initialise without connector!") + connection = await connector.get_connection() if connection is None: raise ValueError("Cannot Init without connection.") info = await EnumInfo.fetch(connection, self.name) diff --git a/bot/data/columns.py b/bot/data/columns.py index 8a14b27e..2fe3b498 100644 --- a/bot/data/columns.py +++ b/bot/data/columns.py @@ -103,9 +103,9 @@ if TYPE_CHECKING: class Column(ColumnExpr, Generic[T]): - def __init__(self, name: str = None, primary: bool = False): + def __init__(self, name: str = None, primary: bool = False): # type: ignore self.primary = primary - self.name: str = name # type: ignore + self.name: str = name self.expr = sql.Identifier(name) if name else sql.SQL('') self.values = () diff --git a/bot/data/models.py b/bot/data/models.py index 38db7a2f..a5a15651 100644 --- a/bot/data/models.py +++ b/bot/data/models.py @@ -131,7 +131,7 @@ class RowModel: # TODO: Proper typing for a classvariable which gets dynamically assigned in subclass table: RowTable - def __init_subclass__(cls: Type[RowT], table: str = None): + def __init_subclass__(cls: Type[RowT], table: Optional[str] = None): """ Set table, _columns_, and _key_. """ diff --git a/bot/data/queries.py b/bot/data/queries.py index 7e50a0cb..118767a4 100644 --- a/bot/data/queries.py +++ b/bot/data/queries.py @@ -169,11 +169,11 @@ class JoinMixin(TableQuery[QueryResult]): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - self._joins: list[Expression, ...] = [] + self._joins: list[Expression] = [] def join(self, target: Union[str, Expression], - on: Optional[Condition] = None, using: Union[Expression, tuple[str, ...]] = None, + on: Optional[Condition] = None, using: Optional[Union[Expression, tuple[str, ...]]] = None, natural=False): available = (on is not None) + (using is not None) + natural if available == 0: @@ -304,9 +304,10 @@ class OrderMixin(TableQuery[QueryResult]): @property def _order_section(self) -> Optional[Expression]: - if self._order is not None: + if self._order: expr = RawExpr.join(*self._order, joiner=sql.SQL(', ')) - expr.expr = sql.SQL("ORDER BY {}").formt(expr.expr) + expr.expr = sql.SQL("ORDER BY {}").format(expr.expr) + return expr else: return None diff --git a/bot/data/registry.py b/bot/data/registry.py index 9e6454a0..0d8fa84d 100644 --- a/bot/data/registry.py +++ b/bot/data/registry.py @@ -24,8 +24,8 @@ class Registry: cls._name = name or cls.__name__ def __init__(self, name=None): - self._conn: Connector = None - self.name: str = name or self._name + self._conn: Optional[Connector] = None + self.name: str = name if name is not None else self._name if self.name is None: raise ValueError("A Registry must have a name!")