Skip to content

Commit

Permalink
Merge branch 'main' into feature/sampling-reconcile-mismatches
Browse files Browse the repository at this point in the history
  • Loading branch information
sundarshankar89 authored Feb 14, 2025
2 parents 36b4dc0 + e02840f commit 7d4b1b3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
20 changes: 14 additions & 6 deletions src/databricks/labs/remorph/transpiler/lsp/lsp_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
import attrs
import yaml

# see https://github.com/databrickslabs/remorph/issues/1378
# pylint: disable=import-private-name
from lsprotocol import types as types_module
from lsprotocol.types import (
InitializeParams,
ClientCapabilities,
Expand All @@ -32,7 +31,6 @@
LanguageKind,
Range as LSPRange,
Position as LSPPosition,
_SPECIAL_PROPERTIES,
DiagnosticSeverity,
)
from pygls.lsp.client import BaseLanguageClient
Expand Down Expand Up @@ -157,9 +155,19 @@ class TranspileDocumentResponse:
jsonrpc: str = attrs.field(default="2.0")


_SPECIAL_PROPERTIES.extend(
[f"{TranspileDocumentRequest.__name__}.method", f"{TranspileDocumentRequest.__name__}.jsonrpc"]
)
def install_special_properties():
is_special_property = getattr(types_module, "is_special_property")

def customized(cls: type, property_name: str) -> bool:
if cls is TranspileDocumentRequest and property_name in {"method", "jsonrpc"}:
return True
return is_special_property(cls, property_name)

setattr(types_module, "is_special_property", customized)


install_special_properties()

METHOD_TO_TYPES[TRANSPILE_TO_DATABRICKS_METHOD] = (
TranspileDocumentRequest,
TranspileDocumentResponse,
Expand Down
20 changes: 14 additions & 6 deletions tests/resources/lsp_transpiler/lsp_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@

import attrs

# see https://github.com/databrickslabs/remorph/issues/1378
# pylint: disable=import-private-name
from lsprotocol import types as types_module
from lsprotocol.types import (
InitializeParams,
INITIALIZE,
Expand All @@ -23,7 +22,6 @@
Range,
Position,
METHOD_TO_TYPES,
_SPECIAL_PROPERTIES,
DiagnosticSeverity,
LanguageKind,
)
Expand Down Expand Up @@ -75,9 +73,19 @@ class TranspileDocumentResponse:
jsonrpc: str = attrs.field(default="2.0")


_SPECIAL_PROPERTIES.extend(
[f"{TranspileDocumentRequest.__name__}.method", f"{TranspileDocumentRequest.__name__}.jsonrpc"]
)
def install_special_properties():
is_special_property = getattr(types_module, "is_special_property")

def customized(cls: type, property_name: str) -> bool:
if cls is TranspileDocumentRequest and property_name in {"method", "jsonrpc"}:
return True
return is_special_property(cls, property_name)

setattr(types_module, "is_special_property", customized)


install_special_properties()

METHOD_TO_TYPES[TRANSPILE_TO_DATABRICKS_METHOD] = (
TranspileDocumentRequest,
TranspileDocumentResponse,
Expand Down

0 comments on commit 7d4b1b3

Please sign in to comment.