@@ -215,13 +215,6 @@ def __init__(
215
215
# Module for which inspection was requested.
216
216
self .module : State | None = None
217
217
218
- def parse_location (self , location : str ) -> tuple [str , list [int ]]:
219
- if location .count (":" ) not in [2 , 4 ]:
220
- raise ValueError ("Format should be file:line:column[:end_line:end_column]" )
221
- parts = location .split (":" )
222
- module , * rest = parts
223
- return module , [int (p ) for p in rest ]
224
-
225
218
def reload_module (self , state : State ) -> None :
226
219
"""Reload given module while temporary exporting types."""
227
220
old = self .fg_manager .manager .options .export_types
@@ -575,7 +568,7 @@ def run_inspection(
575
568
This can be re-used by various simple inspections.
576
569
"""
577
570
try :
578
- file , pos = self . parse_location (location )
571
+ file , pos = parse_location (location )
579
572
except ValueError as err :
580
573
return {"error" : str (err )}
581
574
@@ -617,3 +610,18 @@ def get_definition(self, location: str) -> dict[str, object]:
617
610
result ["out" ] = f"No name or member expressions at { location } "
618
611
result ["status" ] = 1
619
612
return result
613
+
614
+
615
+ def parse_location (location : str ) -> tuple [str , list [int ]]:
616
+ if location .count (":" ) < 2 :
617
+ raise ValueError ("Format should be file:line:column[:end_line:end_column]" )
618
+ parts = location .rsplit (":" , maxsplit = 2 )
619
+ start , * rest = parts
620
+ # Note: we must allow drive prefix like `C:` on Windows.
621
+ if start .count (":" ) < 2 :
622
+ return start , [int (p ) for p in rest ]
623
+ parts = start .rsplit (":" , maxsplit = 2 )
624
+ start , * start_rest = parts
625
+ if start .count (":" ) < 2 :
626
+ return start , [int (p ) for p in start_rest + rest ]
627
+ raise ValueError ("Format should be file:line:column[:end_line:end_column]" )
0 commit comments