elif callable(auth):
return FunctionAuth(func=auth)
else:
- raise TypeError('Invalid "auth" argument.')
+ raise TypeError(f'Invalid "auth" argument: {auth!r}')
def _build_request_auth(
self, request: Request, auth: typing.Union[AuthTypes, UnsetType] = UNSET
self._uri_reference = url._uri_reference
else:
raise TypeError(
- f"Invalid type for url. Expected str or httpx.URL, got {type(url)}"
+ f"Invalid type for url. Expected str or httpx.URL, got {type(url)}: {url!r}"
)
# Add any query parameters, merging with any in the URL if needed.
def __init__(self, name: str, value: typing.Union[str, bytes]) -> None:
if not isinstance(name, str):
- raise TypeError("Invalid type for name. Expected str.")
+ raise TypeError(
+ f"Invalid type for name. Expected str, got {type(name)}: {name!r}"
+ )
if not isinstance(value, (str, bytes)):
- raise TypeError("Invalid type for value. Expected str or bytes.")
+ raise TypeError(
+ f"Invalid type for value. Expected str or bytes, got {type(value)}: {value!r}"
+ )
self.name = name
self.value = value
files=files,
)
assert "Invalid type for name" in str(e.value)
+ assert repr(key) in str(e.value)
@pytest.mark.parametrize(("value"), (1, 2.3, None, [None, "abc"], {None: "abc"}))