Skip to content

Commit d32b452

Browse files
committed
Update the TYPE_ERR_MSG to be compatible with mypy 1.7
1 parent 363bd6b commit d32b452

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

test/test_plugin.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import collections
22
import os
3+
import re
34
import subprocess
45
import sys
56
from pathlib import Path
@@ -18,7 +19,10 @@
1819
DOC_URI = f"file:/{Path(__file__)}"
1920
DOC_TYPE_ERR = """{}.append(3)
2021
"""
21-
TYPE_ERR_MSG = '"Dict[<nothing>, <nothing>]" has no attribute "append"'
22+
23+
# Mypy 1.7 changed <nothing> into "Never", so make this a regex to be compatible
24+
# with multiple versions of mypy
25+
TYPE_ERR_MSG_REGEX = r"\"Dict\[(.+)]\" has no attribute \"append\""
2226

2327
TEST_LINE = 'test_plugin.py:279:8:279:16: error: "Request" has no attribute "id" [attr-defined]'
2428
TEST_LINE_NOTE = (
@@ -66,7 +70,7 @@ def test_plugin(workspace, last_diagnostics_monkeypatch):
6670

6771
assert len(diags) == 1
6872
diag = diags[0]
69-
assert diag["message"] == TYPE_ERR_MSG
73+
assert re.search(TYPE_ERR_MSG_REGEX, diag["message"])
7074
assert diag["range"]["start"] == {"line": 0, "character": 0}
7175
# Running mypy in 3.7 produces wrong error ends this can be removed when 3.7 reaches EOL
7276
if sys.version_info < (3, 8):
@@ -365,7 +369,7 @@ def test_config_exclude(tmpdir, workspace):
365369
plugin.pylsp_settings(workspace._config)
366370
workspace.update_config({"pylsp": {"plugins": {"pylsp_mypy": {}}}})
367371
diags = plugin.pylsp_lint(workspace._config, workspace, doc, is_saved=False)
368-
assert diags[0]["message"] == TYPE_ERR_MSG
372+
assert re.search(TYPE_ERR_MSG_REGEX, diags[0]["message"])
369373

370374
# Add the path of our document to the exclude patterns
371375
exclude_path = doc.path.replace(os.sep, "/")

0 commit comments

Comments
 (0)