From 98f0dfd556ee31d27b407392c42630df7221b09f Mon Sep 17 00:00:00 2001 From: Conner Nilsen Date: Wed, 11 Dec 2024 17:03:06 -0800 Subject: [PATCH] Fix GH tests (#952) Summary: Fixes OSS tests I broke :( Differential Revision: D67107107 --- client/commands/tests/language_server_test.py | 259 ------------------ client/language_server/features.py | 4 +- 2 files changed, 2 insertions(+), 261 deletions(-) diff --git a/client/commands/tests/language_server_test.py b/client/commands/tests/language_server_test.py index b2801d6f321..48590d743a8 100644 --- a/client/commands/tests/language_server_test.py +++ b/client/commands/tests/language_server_test.py @@ -1642,265 +1642,6 @@ async def test_did_change__basic(self) -> None: expectations, ) - @setup.async_test - async def test_did_change__with_type_errors(self) -> None: - unsaved_file_content = "# some example code" - tracked_path = Path("/tracked.py") - for telemetry in ( - features.TelemetryAvailability.ENABLED, - features.TelemetryAvailability.DISABLED, - ): - querier = server_setup.MockDaemonQuerier( - mock_type_errors={ - tracked_path: [ - error.Error( - line=1, - column=1, - stop_line=2, - stop_column=2, - path=Path("/tracked.py"), - code=42, - name="name", - description="description", - ), - ] - } - ) - setup = server_setup.create_pyre_language_server_api_setup( - opened_documents={ - tracked_path: state.OpenedDocumentState( - code=unsaved_file_content, - ) - }, - querier=querier, - server_options=server_setup.create_server_options( - language_server_features=features.LanguageServerFeatures( - unsaved_changes=features.UnsavedChangesAvailability.ENABLED, - telemetry=telemetry, - ), - ), - ) - api = setup.api - output_writer = setup.output_writer - await api.process_did_change_request( - parameters=lsp.DidChangeTextDocumentParameters( - text_document=lsp.TextDocumentIdentifier( - uri=lsp.DocumentUri.from_file_path(tracked_path).unparse(), - ), - content_changes=[lsp.ContentChange(text=unsaved_file_content)], - ), - ) - # When unsaved changes is not enabled, we should send no requests. - self.assertEqual( - querier.requests, - [ - {"path": tracked_path, "code": unsaved_file_content}, - ], - ) - expect_diagnostics = self._expect_diagnostics( - uri="file:///tracked.py", - diagnostics=[ - lsp.Diagnostic( - range=lsp.LspRange( - start=lsp.LspPosition(line=0, character=1), - end=lsp.LspPosition(line=1, character=2), - ), - message="description", - severity=lsp.DiagnosticSeverity.ERROR, - code="pyre (documentation link)", - source="Pyre", - code_description=lsp.CodeDescription( - href="https://pyre-check.org/docs/errors/#42-missing-overload-implementation" - ), - ) - ], - ) - if telemetry.is_enabled(): - expectations = [ - self._expect_telemetry_event( - operation="didChange", - result=None, - ), - expect_diagnostics, - self._expect_telemetry_event( - operation="typeErrors", - result=None, - ), - ] - else: - expectations = [expect_diagnostics] - self._assert_output_messages( - output_writer, - expectations, - ) - - @setup.async_test - async def test_did_change__no_type_errors(self) -> None: - tracked_path = Path("/tracked.py") - for telemetry in ( - features.TelemetryAvailability.ENABLED, - features.TelemetryAvailability.DISABLED, - ): - querier = server_setup.MockDaemonQuerier( - mock_type_errors={}, - ) - setup = server_setup.create_pyre_language_server_api_setup( - opened_documents={ - tracked_path: state.OpenedDocumentState( - code=server_setup.DEFAULT_FILE_CONTENTS - ) - }, - querier=querier, - server_options=server_setup.create_server_options( - language_server_features=features.LanguageServerFeatures( - unsaved_changes=features.UnsavedChangesAvailability.ENABLED, - telemetry=telemetry, - ), - ), - ) - api = setup.api - output_writer = setup.output_writer - await api.process_did_change_request( - parameters=lsp.DidChangeTextDocumentParameters( - text_document=lsp.TextDocumentIdentifier( - uri=lsp.DocumentUri.from_file_path(tracked_path).unparse(), - ), - content_changes=[ - lsp.ContentChange(text=server_setup.DEFAULT_FILE_CONTENTS) - ], - ), - ) - # When unsaved changes is not enabled, we should send no requests. - self.assertEqual( - querier.requests, - [ - {"path": tracked_path, "code": server_setup.DEFAULT_FILE_CONTENTS}, - ], - ) - expect_diagnostics = self._expect_diagnostics( - uri="file:///tracked.py", - diagnostics=[], - ) - if telemetry.is_enabled(): - expectations = [ - self._expect_telemetry_event( - operation="didChange", - result=None, - ), - expect_diagnostics, - self._expect_telemetry_event( - operation="typeErrors", - result=None, - ), - ] - else: - expectations = [expect_diagnostics] - self._assert_output_messages( - output_writer, - expectations, - ) - - @setup.async_test - async def test_did_change__debounce(self) -> None: - unsaved_file_content_list = [f"# some example code {i}" for i in range(3)] - tracked_path = Path("/tracked.py") - querier = server_setup.MockDaemonQuerier( - mock_type_errors={ - tracked_path: [ - error.Error( - line=1, - column=1, - stop_line=2, - stop_column=2, - path=Path("/tracked.py"), - code=42, - name="name", - description="description", - ), - ] - } - ) - setup = server_setup.create_pyre_language_server_api_setup( - opened_documents={ - tracked_path: state.OpenedDocumentState( - code=unsaved_file_content_list[0], - ) - }, - querier=querier, - server_options=server_setup.create_server_options( - language_server_features=features.LanguageServerFeatures( - unsaved_changes=features.UnsavedChangesAvailability.ENABLED, - type_errors=features.TypeErrorsAvailability.ENABLED, - telemetry=features.TelemetryAvailability.ENABLED, - ), - ), - ) - api = setup.api - output_writer = setup.output_writer - for i in range(len(unsaved_file_content_list)): - await api.process_did_change_request( - parameters=lsp.DidChangeTextDocumentParameters( - text_document=lsp.TextDocumentIdentifier( - uri=lsp.DocumentUri.from_file_path(tracked_path).unparse(), - ), - content_changes=[ - lsp.ContentChange(text=unsaved_file_content_list[i]) - ], - ), - ) - setup.server_state.status_tracker.set_status( - state.ConnectionStatus.INCREMENTAL_CHECK - ) - self.assertEqual( - querier.requests, - [ - # we expect to be able to send only the first request, since the - # remaining requests will put the server in a non-ready state - {"path": tracked_path, "code": unsaved_file_content_list[0]} - ], - ) - expect_diagnostics = self._expect_diagnostics( - uri="file:///tracked.py", - diagnostics=[ - lsp.Diagnostic( - range=lsp.LspRange( - start=lsp.LspPosition(line=0, character=1), - end=lsp.LspPosition(line=1, character=2), - ), - message="description", - severity=lsp.DiagnosticSeverity.ERROR, - code="pyre (documentation link)", - source="Pyre", - code_description=lsp.CodeDescription( - href="https://pyre-check.org/docs/errors/#42-missing-overload-implementation" - ), - ) - ], - ) - expectations = [ - self._expect_telemetry_event( - operation="didChange", - result=None, - ), - expect_diagnostics, - self._expect_telemetry_event( - operation="typeErrors", - result=None, - ), - self._expect_telemetry_event( - operation="didChange", - result=None, - ), - self._expect_telemetry_event( - operation="didChange", - result=None, - ), - ] - self._assert_output_messages( - output_writer, - expectations, - ) - class HoverTest(ApiTestCase): @setup.async_test diff --git a/client/language_server/features.py b/client/language_server/features.py index 37d4b5bc186..a0a4e94f876 100644 --- a/client/language_server/features.py +++ b/client/language_server/features.py @@ -121,7 +121,7 @@ class LanguageServerFeatures: GlobalLazyTypeErrorsAvailability.ENABLED ) per_target_type_errors: PerTargetTypeErrorsAvailability = ( - PerTargetTypeErrorsAvailability.ENABLED + PerTargetTypeErrorsAvailability.DISABLED ) unsaved_changes: UnsavedChangesAvailability = UnsavedChangesAvailability.DISABLED telemetry: TelemetryAvailability = TelemetryAvailability.DISABLED @@ -132,7 +132,7 @@ class LanguageServerFeatures: inlay_hint: InlayHintAvailability = InlayHintAvailability.DISABLED formatting: FormattingAvailability = FormattingAvailability.DISABLED python_auto_targets: PythonAutoTargetsAvailability = ( - PythonAutoTargetsAvailability.ENABLED + PythonAutoTargetsAvailability.DISABLED ) use_system_pyautotargets: SystemPyAutoTargetsAvailability = ( SystemPyAutoTargetsAvailability.from_enabled(False)