MCPcopy Index your code
hub / github.com/python/cpython / _validate_arguments

Function _validate_arguments

Lib/profiling/sampling/_sync_coordinator.py:38–71  ·  view source on GitHub ↗

Validate and parse command line arguments. Args: args: Command line arguments including script name Returns: Tuple of (sync_port, working_directory, target_args) Raises: ArgumentError: If arguments are invalid

(args: List[str])

Source from the content-addressed store, hash-verified

36
37
38def _validate_arguments(args: List[str]) -> tuple[int, str, List[str]]:
39 """
40 Validate and parse command line arguments.
41
42 Args:
43 args: Command line arguments including script name
44
45 Returns:
46 Tuple of (sync_port, working_directory, target_args)
47
48 Raises:
49 ArgumentError: If arguments are invalid
50 """
51 if len(args) < 4:
52 raise ArgumentError(
53 "Insufficient arguments. Expected: <sync_port> <cwd> <target> [args...]"
54 )
55
56 try:
57 sync_port = int(args[1])
58 if not (1 <= sync_port <= 65535):
59 raise ValueError("Port out of range")
60 except ValueError as e:
61 raise ArgumentError(f"Invalid sync port '{args[1]}': {e}") from e
62
63 cwd = args[2]
64 if not os.path.isdir(cwd):
65 raise ArgumentError(f"Working directory does not exist: {cwd}")
66
67 target_args = args[3:]
68 if not target_args:
69 raise ArgumentError("No target specified")
70
71 return sync_port, cwd, target_args
72
73
74# Constants for socket communication

Callers 1

mainFunction · 0.85

Calls 2

ArgumentErrorClass · 0.70
isdirMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…