From 3ae1adbcd5e3f79df882300b3e7253036af13970 Mon Sep 17 00:00:00 2001 From: Jiaqi Lv Date: Thu, 11 Apr 2024 17:35:11 +0100 Subject: [PATCH] partial fix dsl.py --- .github/workflows/mypy-type-check.yml | 3 ++- tiatoolbox/annotation/dsl.py | 16 ++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/mypy-type-check.yml b/.github/workflows/mypy-type-check.yml index eec54d6a9..3cdb2c149 100644 --- a/.github/workflows/mypy-type-check.yml +++ b/.github/workflows/mypy-type-check.yml @@ -40,4 +40,5 @@ jobs: tiatoolbox/typing.py \ tiatoolbox/tiatoolbox.py \ tiatoolbox/utils/*.py \ - tiatoolbox/tools/*.py + tiatoolbox/tools/*.py \ + tiatoolbox/data/*.py diff --git a/tiatoolbox/annotation/dsl.py b/tiatoolbox/annotation/dsl.py index 81693f443..ef384d2a9 100644 --- a/tiatoolbox/annotation/dsl.py +++ b/tiatoolbox/annotation/dsl.py @@ -160,7 +160,7 @@ def __eq__(self: SQLExpression, other: SQLExpression) -> SQLTriplet: """Define how the object is compared for equality.""" return SQLTriplet(self, operator.eq, other) - def __ne__(self: SQLExpression, other: object) -> SQLTriplet: + def __ne__(self: SQLExpression, other: SQLExpression) -> SQLTriplet: """Define how the object is compared for equality (not equal to).""" return SQLTriplet(self, operator.ne, other) @@ -168,7 +168,7 @@ def __neg__(self: SQLExpression) -> SQLTriplet: """Define how the object is compared for negation (not equal to).""" return SQLTriplet(self, operator.neg) - def __contains__(self: SQLExpression, other: object) -> bool: + def __contains__(self: SQLExpression, other: SQLExpression) -> bool: """Test whether the object contains the specified object or not.""" return SQLTriplet(self, "contains", other) @@ -180,19 +180,19 @@ def __rpow__(self: SQLExpression, x: SQLTriplet | str) -> SQLTriplet: """Implements reverse exponentiation operation.""" return SQLTriplet(x, operator.pow, self) - def __and__(self: SQLExpression, other: object) -> SQLTriplet: + def __and__(self: SQLExpression, other: SQLExpression) -> SQLTriplet: """Implements logical AND operation.""" return SQLTriplet(self, operator.and_, other) - def __rand__(self: SQLExpression, other: object) -> SQLTriplet: + def __rand__(self: SQLExpression, other: SQLExpression) -> SQLTriplet: """Implements reverse logical AND operation.""" return SQLTriplet(other, operator.and_, self) - def __or__(self: SQLExpression, other: object) -> SQLTriplet: + def __or__(self: SQLExpression, other: SQLExpression) -> SQLTriplet: """Implements logical OR operation.""" return SQLTriplet(self, operator.or_, other) - def __ror__(self: SQLExpression, other: object) -> SQLTriplet: + def __ror__(self: SQLExpression, other: SQLExpression) -> SQLTriplet: """Implements reverse logical OR operation.""" return SQLTriplet(other, operator.or_, self) @@ -209,9 +209,9 @@ class SQLTriplet(SQLExpression): def __init__( self: SQLExpression, - lhs: SQLTriplet | str, + lhs: SQLTriplet | str | SQLExpression |Number, op: Callable | str | None = None, - rhs: SQLTriplet | str | None = None, + rhs: SQLTriplet | str | SQLExpression| Number | None = None, ) -> None: """Initialize :class:`SQLTriplet`.""" self.lhs = lhs