Skip to content

Commit

Permalink
Assert on rather than cast SqlColumnVisitor types.
Browse files Browse the repository at this point in the history
  • Loading branch information
TallJimbo committed Apr 4, 2024
1 parent df66e92 commit d5b742e
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

__all__ = ("SqlColumnVisitor",)

from typing import TYPE_CHECKING, Any, cast
from typing import TYPE_CHECKING, Any

import sqlalchemy

Expand Down Expand Up @@ -257,7 +257,11 @@ def apply_logical_not(
return sqlalchemy.not_(result)

def expect_scalar(self, expression: qt.OrderExpression) -> sqlalchemy.ColumnElement[Any]:
return cast(sqlalchemy.ColumnElement[Any], expression.visit(self))
result = expression.visit(self)
assert isinstance(result, sqlalchemy.ColumnElement)
return result

def expect_timespan(self, expression: qt.ColumnExpression) -> TimespanDatabaseRepresentation:
return cast(TimespanDatabaseRepresentation, expression.visit(self))
result = expression.visit(self)
assert isinstance(result, TimespanDatabaseRepresentation)
return result

0 comments on commit d5b742e

Please sign in to comment.