diff --git a/bundled/tool/lsp_server.py b/bundled/tool/lsp_server.py index f639b22..ea227c5 100644 --- a/bundled/tool/lsp_server.py +++ b/bundled/tool/lsp_server.py @@ -182,6 +182,9 @@ def _parse_output_using_regex( message=data.get("message"), severity=_get_severity(data["code"], data["type"], severity), code=data["code"], + code_description=lsp.CodeDescription( + href=utils.ERROR_CODE_BASE_URL + data["code"] + ), source=TOOL_DISPLAY, ) diagnostics.append(diagnostic) diff --git a/bundled/tool/lsp_utils.py b/bundled/tool/lsp_utils.py index 57695f5..0a0845e 100644 --- a/bundled/tool/lsp_utils.py +++ b/bundled/tool/lsp_utils.py @@ -18,6 +18,7 @@ # Save the working directory used when loading this module SERVER_CWD = os.getcwd() CWD_LOCK = threading.Lock() +ERROR_CODE_BASE_URL = "https://mypy.readthedocs.io/en/latest/_refs.html#code-" def as_list(content: Union[Any, List[Any], Tuple[Any]]) -> List[Any]: diff --git a/src/test/python_tests/test_linting.py b/src/test/python_tests/test_linting.py index cf5661f..fb2fce9 100644 --- a/src/test/python_tests/test_linting.py +++ b/src/test/python_tests/test_linting.py @@ -63,6 +63,9 @@ def _log_handler(params): "message": 'Name "x" is not defined ', "severity": 1, "code": "name-defined", + "codeDescription": { + "href": "https://mypy.readthedocs.io/en/latest/_refs.html#code-name-defined" + }, "source": "Mypy", } ], @@ -117,6 +120,9 @@ def _log_handler(params): "message": 'Name "x" is not defined ', "severity": 1, "code": "name-defined", + "codeDescription": { + "href": "https://mypy.readthedocs.io/en/latest/_refs.html#code-name-defined" + }, "source": "Mypy", } ], @@ -236,6 +242,9 @@ def _log_handler(params): "message": 'Name "x" is not defined ', "severity": 2, "code": "name-defined", + "codeDescription": { + "href": "https://mypy.readthedocs.io/en/latest/_refs.html#code-name-defined" + }, "source": "Mypy", } ],