Skip to content

Commit adeccb4

Browse files
committed
Allow dmypy suggest paths to contain drive letter colon in Windows machines
Fixes #19335
1 parent 16e99de commit adeccb4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

mypy/suggestions.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import itertools
2828
import json
2929
import os
30+
import sys
3031
from collections.abc import Iterator
3132
from contextlib import contextmanager
3233
from typing import Callable, NamedTuple, TypedDict, TypeVar, cast
@@ -549,12 +550,13 @@ def find_node(self, key: str) -> tuple[str, str, FuncDef]:
549550
# TODO: Also return OverloadedFuncDef -- currently these are ignored.
550551
node: SymbolNode | None = None
551552
if ":" in key:
552-
if key.count(":") > 1:
553+
platform_key_count = 2 if sys.platform == "win32" else 1
554+
if key.count(":") > platform_key_count:
553555
raise SuggestionFailure(
554556
"Malformed location for function: {}. Must be either"
555557
" package.module.Class.method or path/to/file.py:line".format(key)
556558
)
557-
file, line = key.split(":")
559+
file, line = key.rsplit(":", 1)
558560
if not line.isdigit():
559561
raise SuggestionFailure(f"Line number must be a number. Got {line}")
560562
line_number = int(line)

0 commit comments

Comments
 (0)