FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Lessen dmypy suggest path limitations for Windows machines by CoolCat467 · Pull Request #19337 · python/mypy · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
10 changes: 8 additions & 2 deletions mypy/suggestions.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import itertools
import json
import os
import sys
from collections.abc import Iterator
from contextlib import contextmanager
from typing import Callable, NamedTuple, TypedDict, TypeVar, cast
Expand Down Expand Up @@ -549,12 +550,17 @@ def find_node(self, key: str) -> tuple[str, str, FuncDef]:
# TODO: Also return OverloadedFuncDef -- currently these are ignored.
node: SymbolNode | None = None
if ":" in key:
if key.count(":") > 1:
# A colon might be part of a drive name on Windows (like `C:/foo/bar`)
# and is also used as a delimiter between file path and lineno.
# If a colon is there for any of those reasons, it must be a file+line
# reference.
platform_key_count = 2 if sys.platform == "win32" else 1
Comment thread
CoolCat467 marked this conversation as resolved.
if key.count(":") > platform_key_count:
raise SuggestionFailure(
"Malformed location for function: {}. Must be either"
" package.module.Class.method or path/to/file.py:line".format(key)
)
file, line = key.split(":")
file, line = key.rsplit(":", 1)
if not line.isdigit():
raise SuggestionFailure(f"Line number must be a number. Got {line}")
line_number = int(line)
Expand Down

Back | FazBrowse Home | New Git URL