Validate that args count is within expected range. Raises ValueError if the count is outside the expected range. Args: args: The handler args list min_count: Minimum number of args expected max_count: Maximum number of args expected op_name: Name of the
(
args: List[Any],
min_count: int,
max_count: int,
op_name: str,
)
| 219 | |
| 220 | |
| 221 | def require_args( |
| 222 | args: List[Any], |
| 223 | min_count: int, |
| 224 | max_count: int, |
| 225 | op_name: str, |
| 226 | ) -> None: |
| 227 | """ |
| 228 | Validate that args count is within expected range. |
| 229 | |
| 230 | Raises ValueError if the count is outside the expected range. |
| 231 | |
| 232 | Args: |
| 233 | args: The handler args list |
| 234 | min_count: Minimum number of args expected |
| 235 | max_count: Maximum number of args expected |
| 236 | op_name: Name of the operation (for error message) |
| 237 | """ |
| 238 | if not (min_count <= len(args) <= max_count): |
| 239 | if min_count == max_count: |
| 240 | raise ValueError(f"{op_name}: expected {min_count} args, got {len(args)}") |
| 241 | raise ValueError( |
| 242 | f"{op_name}: expected {min_count}-{max_count} args, got {len(args)}" |
| 243 | ) |
| 244 | |
| 245 | |
| 246 | def require_kwargs( |
no outgoing calls
no test coverage detected