Hi everyone,
While writing some tests, I encountered an issue with Pyright, which is reporting partially unknown types, and I'm not sure how to fix it.
Here is my test function:
with pytest.raises(ExceptionGroup) as exc_info:
tablerone_partial(
padding_horizontal_no_border=paddings[0],
padding_vertical_no_border=paddings[1],
padding_horizontal_with_border=paddings[2],
padding_vertical_with_border=paddings[3],
)
assert all(isinstance(exc, InvalidPaddingValueError) for exc in exc_info.value.exceptions)
In this case, I'm trying to ensure that tablerone_partial raises an ExceptionGroup that only contains InvalidPaddingValueError. The ExceptionGroup holds a more generic exception type, and InvalidPaddingValueError inherits from that generic exception type.
Here are the errors shown by Pyright:
test_args.py:27:43 - error: Type of "exc_info" is partially unknown
Type of "exc_info" is "ExceptionInfo[ExceptionGroup[Unknown]]" (reportUnknownVariableType)
test_args.py:34:62 - error: Type of "exc" is partially unknown
Type of "exc" is "Unknown | ExceptionGroup[Unknown]" (reportUnknownVariableType)
test_args.py:34:69 - error: Type of "value" is partially unknown
Type of "value" is "ExceptionGroup[Unknown]" (reportUnknownMemberType)
test_args.py:34:69 - error: Type of "exceptions" is partially unknown
Type of "exceptions" is "tuple[Unknown | ExceptionGroup[Unknown], ...]" (reportUnknownMemberType)
I've tried adding type hints to the ExceptionGroup raised by the tablerone_partial function, but it didn't help. (Mypy doesn't show any errors.)
How can I hint the exc_info to make Pyright recognize the type? Or should I be approaching this differently?
Thanks in advance for any help!