Skip to content

Commit

Permalink
Test fix / review feedback.
Browse files Browse the repository at this point in the history
[ci skip-rust]

[ci skip-build-wheels]
  • Loading branch information
stuhood committed Jul 10, 2022
1 parent 6f177e1 commit 1cb5c30
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
19 changes: 6 additions & 13 deletions src/python/pants/bsp/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,19 +157,12 @@ def _handle_inbound_message(self, *, method_name: str, params: Any):
execution_request = self._scheduler_session.execution_request(
requests=[(method_mapping.response_type, params)],
)
returns, throws = self._scheduler_session.execute(execution_request)
if len(returns) == 1 and len(throws) == 0:
# Initialize the BSPContext with the client-supplied init parameters. See earlier comment on why this
# call to `BSPContext.initialize_connection` is safe.
if method_name == self._INITIALIZE_METHOD_NAME:
self._context.initialize_connection(request, self.notify_client)
return returns[0][1].value.to_json_dict()
elif len(returns) == 0 and len(throws) == 1:
raise throws[0][1].exc
else:
raise AssertionError(
f"Received unexpected result from engine: returns={returns}; throws={throws}"
)
(result,) = self._scheduler_session.execute(execution_request)
# Initialize the BSPContext with the client-supplied init parameters. See earlier comment on why this
# call to `BSPContext.initialize_connection` is safe.
if method_name == self._INITIALIZE_METHOD_NAME:
self._context.initialize_connection(request, self.notify_client)
return result.to_json_dict()

# Called by `Endpoint` to dispatch requests and notifications.
# TODO: Should probably vendor `Endpoint` so we can detect notifications versus method calls, which
Expand Down
4 changes: 2 additions & 2 deletions src/python/pants/engine/streaming_workunit_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import threading
from abc import ABC, abstractmethod
from dataclasses import dataclass
from typing import Any, Callable, Dict, Iterable, Sequence, Tuple
from typing import Any, Callable, Iterable, Sequence, Tuple

from pants.base.specs import Specs
from pants.engine.addresses import Addresses
Expand Down Expand Up @@ -106,7 +106,7 @@ def get_expanded_specs(self) -> ExpandedSpecs:
request = self._scheduler.execution_request([(Addresses, params), (Targets, params)])
unexpanded_addresses, expanded_targets = self._scheduler.execute(request)

targets_dict: Dict[str, list[TargetInfo]] = {str(addr): [] for addr in unexpanded_addresses}
targets_dict: dict[str, list[TargetInfo]] = {str(addr): [] for addr in unexpanded_addresses}
for target in expanded_targets:
source = targets_dict.get(str(target.address.spec), None)
if source is None:
Expand Down
3 changes: 2 additions & 1 deletion src/python/pants/jvm/testutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ def rules():
return [
*collect_rules(),
*system_binaries.rules(),
QueryRule(CoarsenedTargets, (Addresses,)),
QueryRule(RenderedClasspath, (Classpath,)),
QueryRule(RenderedClasspath, (ClasspathEntry,)),
QueryRule(CoarsenedTargets, (Addresses,)),
QueryRule(Targets, (Addresses,)),
]

0 comments on commit 1cb5c30

Please sign in to comment.