Skip to content

Commit

Permalink
Ignore failed inference codes when presenting results to Databricks R…
Browse files Browse the repository at this point in the history
…untime (#3087)

This PR disables the following advice codes from being propagated in our
notebook editor:

- 'cannot-autofix-table-reference',
- 'default-format-changed-in-dbr8',
- 'dependency-not-found',
- 'not-supported',
- 'notebook-run-cannot-compute-value',
- 'sql-parse-error',
- 'sys-path-cannot-compute-value',
- 'unsupported-magic-line',
  • Loading branch information
nfx authored Oct 30, 2024
1 parent baefc8f commit 1ad3649
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/databricks/labs/ucx/source_code/lsp_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@
logger = logging.getLogger(__name__)


DEBUG_MESSAGE_CODES = {
'cannot-autofix-table-reference',
'default-format-changed-in-dbr8',
'dependency-not-found',
'not-supported',
'notebook-run-cannot-compute-value',
'sql-parse-error',
'sys-path-cannot-compute-value',
'unsupported-magic-line',
}


@hookimpl
def pylsp_lint(config: Config, document: Document) -> list[dict]:
cfg = config.plugin_settings('pylsp_ucx', document_path=document.uri)
Expand All @@ -29,7 +41,7 @@ def pylsp_lint(config: Config, document: Document) -> list[dict]:
languages = LinterContext(index=migration_index, session_state=session_state)
analyser = languages.linter(Language.PYTHON)
code = document.source
diagnostics = [Diagnostic.from_advice(_) for _ in analyser.lint(code)]
diagnostics = [Diagnostic.from_advice(_) for _ in analyser.lint(code) if _.code not in DEBUG_MESSAGE_CODES]
return [d.as_dict() for d in diagnostics]


Expand Down

0 comments on commit 1ad3649

Please sign in to comment.