Skip to content

Commit

Permalink
gk control removals feature
Browse files Browse the repository at this point in the history
Reviewed By: zsol, connernilsen

Differential Revision: D64224052

fbshipit-source-id: 735e5f017261b319a16a3e82c05815b1e62882e9
  • Loading branch information
AishwaryaSivaraman authored and facebook-github-bot committed Oct 11, 2024
1 parent 1308c7f commit f9e9b69
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
25 changes: 15 additions & 10 deletions client/commands/pyre_language_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,7 @@ async def process_did_change_request(
async def _run_python_auto_targets(
self,
changed_file: Path,
removals_enabled: bool,
) -> PythonAutoTargetsMetadata:
try:
buck2_root = get_buck_root()
Expand Down Expand Up @@ -1073,15 +1074,18 @@ async def _run_python_auto_targets(
)
else Path(f"{buck2_root}/xplat/tools/pyautotargets")
)

pyautodeps_parameters = [
str(pyautotargets_bin),
"--verbose",
"--buck-root",
buck2_root,
"--isolation-dir=.pyautotargets",
str(changed_file),
]
pyautodeps_parameters = [str(pyautotargets_bin)]
if removals_enabled:
pyautodeps_parameters.append("--remove-deps")
pyautodeps_parameters.extend(
[
"--verbose",
"--buck-root",
buck2_root,
"--isolation-dir=.pyautotargets",
str(changed_file),
]
)
LOG.debug(f"Running Pyautotargets: `{' '.join(pyautodeps_parameters)}`")
pyautodeps_run = await asyncio.create_subprocess_exec(
*pyautodeps_parameters,
Expand Down Expand Up @@ -1138,7 +1142,8 @@ async def process_did_save_request(
):
async with self.server_state.pyautotargets_lock:
auto_targets_metadata = await self._run_python_auto_targets(
document_path
document_path,
self.get_language_server_features().python_auto_targets_removal.is_enabled(),
)
else:
auto_targets_metadata = PythonAutoTargetsMetadata(
Expand Down
6 changes: 6 additions & 0 deletions client/language_server/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ def is_disabled(self) -> bool:
PerTargetTypeErrorsAvailability = CustomAvailability
PythonAutoTargetsAvailability = CustomAvailability
SystemPyAutoTargetsAvailability = CustomAvailability
# TODO: T204372341 remove this once we have rolled out addition and removal features
PythonAutoTargetsRemovalAvailability = CustomAvailability

# Telemetry: is the editor able to forward events somewhere?
TelemetryAvailability = _Availability
Expand Down Expand Up @@ -131,6 +133,10 @@ class LanguageServerFeatures:
use_system_pyautotargets: SystemPyAutoTargetsAvailability = (
SystemPyAutoTargetsAvailability.from_enabled(False)
)
# TODO: T204372341 remove this once we have rolled out addition and removal features
python_auto_targets_removal: PythonAutoTargetsRemovalAvailability = (
PythonAutoTargetsRemovalAvailability.from_enabled(False)
)

def capabilities(self) -> Dict[str, bool]:
return {
Expand Down

0 comments on commit f9e9b69

Please sign in to comment.