(
pos_kwargs: Mapping[Any, T] | None,
kw_kwargs: Mapping[str, T],
func_name: str,
)
| 182 | |
| 183 | |
| 184 | def either_dict_or_kwargs( |
| 185 | pos_kwargs: Mapping[Any, T] | None, |
| 186 | kw_kwargs: Mapping[str, T], |
| 187 | func_name: str, |
| 188 | ) -> Mapping[Hashable, T]: |
| 189 | if pos_kwargs is None or pos_kwargs == {}: |
| 190 | # Need an explicit cast to appease mypy due to invariance; see |
| 191 | # https://github.com/python/mypy/issues/6228 |
| 192 | return cast(Mapping[Hashable, T], kw_kwargs) |
| 193 | |
| 194 | if not is_dict_like(pos_kwargs): |
| 195 | raise ValueError(f"the first argument to .{func_name} must be a dictionary") |
| 196 | if kw_kwargs: |
| 197 | raise ValueError( |
| 198 | f"cannot specify both keyword and positional arguments to .{func_name}" |
| 199 | ) |
| 200 | return pos_kwargs |
| 201 | |
| 202 | |
| 203 | def _get_chunk( # type: ignore[no-untyped-def] |
searching dependent graphs…