Skip to content

Fixture functions can't have a return type hint #237

@lheckemann

Description

@lheckemann

Trying to define a fixture as follows:

@pytest_lsp.fixture(
    scope="module",
    config=pytest_lsp.ClientServerConfig(server_command=[sys.executable, "-m", "pkdev.translation_lsp"]),
)
async def mylsp_client(lsp_client: pytest_lsp.LanguageClient) -> AsyncGenerator[None]:
    await lsp_client.initialize_session(InitializeParams(ClientCapabilities()))
    yield
    await lsp_client.shutdown_session()

results in a type error:

        # Inject the language client
        for name, cls in typing.get_type_hints(fn).items():
>           if issubclass(cls, JsonRPCClient):
E           TypeError: issubclass() arg 1 must be a class

.../site-packages/pytest_lsp/plugin.py:196: TypeError

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions