Skip to content

Commit cc02c2c

Browse files
committed
tests: Cast _LoggingPool to ThreadPoolExecutor
c:\Dev\nipanel-python\tests\conftest.py c:\Dev\nipanel-python\tests\conftest.py:20:23 - error: Argument of type "_LoggingPool" cannot be assigned to parameter "thread_pool" of type "ThreadPoolExecutor" in function "start"   "_LoggingPool" is not assignable to "ThreadPoolExecutor" (reportArgumentType)
1 parent 342a830 commit cc02c2c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

tests/conftest.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
"""Fixtures for testing."""
22

33
from collections.abc import Generator
4+
from concurrent.futures import ThreadPoolExecutor
5+
from typing import cast
46

57
import grpc
68
import pytest
79
from grpc.framework.foundation import logging_pool
8-
from ni.pythonpanel.v1.python_panel_service_pb2_grpc import (
9-
PythonPanelServiceStub,
10-
)
1110

11+
from ni.pythonpanel.v1.python_panel_service_pb2_grpc import PythonPanelServiceStub
1212
from tests.utils._fake_python_panel_service import FakePythonPanelService
1313

1414

1515
@pytest.fixture
1616
def fake_python_panel_service() -> Generator[FakePythonPanelService]:
1717
"""Fixture to create a FakePythonPanelServicer for testing."""
1818
with logging_pool.pool(max_workers=10) as thread_pool:
19+
# _LoggingPool is not a ThreadPoolExecutor, but it's duck-typing compatible with one.
20+
thread_pool = cast(ThreadPoolExecutor, thread_pool)
1921
service = FakePythonPanelService()
2022
service.start(thread_pool)
2123
yield service

0 commit comments

Comments
 (0)