Skip to content

Commit 22a47b6

Browse files
committed
Document reasons for # type: ignore in _formula_engine.py
Signed-off-by: Sahas Subramanian <[email protected]>
1 parent b509bfd commit 22a47b6

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/frequenz/sdk/timeseries/_formula_engine/_formula_engine.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,12 @@ async def apply(self) -> Sample[QuantityT]:
192192
"HigherOrderFormulaBuilder3Phase",
193193
]
194194

195+
# The `FormulaEngine*` and `HigherOrderFormulaBuilder*` classes are generic, but
196+
# `TypeVar`s can't be defined on generic types, so we need to use `# type: ignore` to
197+
# avoid mypy errors, and they get treated as `FormulaEngine[Any]`, etc.
198+
#
199+
# This is not ideal, but it's the best we can do until mypy supports generic types with
200+
# `TypeVar`s.
195201
_GenericEngine = TypeVar(
196202
"_GenericEngine",
197203
"FormulaEngine", # type: ignore
@@ -204,6 +210,9 @@ async def apply(self) -> Sample[QuantityT]:
204210
)
205211

206212

213+
# This class has multiple generic type parameters that should also restrict each other,
214+
# but mypy doesn't support that, so we need to use `# type: ignore` in several places in
215+
# this, and subsequent classes, to avoid mypy errors.
207216
class _ComposableFormulaEngine(
208217
ABC, Generic[_GenericEngine, _GenericHigherOrderBuilder, QuantityT]
209218
):

0 commit comments

Comments
 (0)