Skip to content

Commit

Permalink
Link to mypy's error code documentation (#58)
Browse files Browse the repository at this point in the history
* Link to mypy's error code documentation

* Apply suggestions from code review

Co-authored-by: Karthik Nadig <kanadig@microsoft.com>

* Ran black

* Updated to use the new consistent error code anchors

---------

Co-authored-by: Karthik Nadig <kanadig@microsoft.com>
  • Loading branch information
Avasam and karthiknadig committed Jun 21, 2023
1 parent ee97f67 commit ea18cf0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions bundled/tool/lsp_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions bundled/tool/lsp_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down
9 changes: 9 additions & 0 deletions src/test/python_tests/test_linting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
],
Expand Down Expand Up @@ -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",
}
],
Expand Down Expand Up @@ -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",
}
],
Expand Down

0 comments on commit ea18cf0

Please sign in to comment.