diff --git a/httpx/_multipart.py b/httpx/_multipart.py index 2c08776f4b..cf8f76b601 100644 --- a/httpx/_multipart.py +++ b/httpx/_multipart.py @@ -43,14 +43,6 @@ class DataField: def __init__( self, name: str, value: typing.Union[str, bytes, int, float, None] ) -> None: - if not isinstance(name, str): - raise TypeError( - f"Invalid type for name. Expected str, got {type(name)}: {name!r}" - ) - if value is not None and not isinstance(value, (str, bytes, int, float)): - raise TypeError( - f"Invalid type for value. Expected primitive type, got {type(value)}: {value!r}" - ) self.name = name self.value: typing.Union[str, bytes] = ( value if isinstance(value, bytes) else primitive_value_to_str(value) diff --git a/tests/test_multipart.py b/tests/test_multipart.py index 1d9c12feea..9a0b8b5665 100644 --- a/tests/test_multipart.py +++ b/tests/test_multipart.py @@ -92,33 +92,6 @@ def test_multipart_header_without_boundary(header: str) -> None: assert response.request.headers["Content-Type"] == header -@pytest.mark.parametrize(("key"), (b"abc", 1, 2.3, None)) -def test_multipart_invalid_key(key): - client = httpx.Client(transport=httpx.MockTransport(echo_request_content)) - - data = {key: "abc"} - files = {"file": io.BytesIO(b"")} - with pytest.raises(TypeError) as e: - client.post( - "http://127.0.0.1:8000/", - data=data, - files=files, - ) - assert "Invalid type for name" in str(e.value) - assert repr(key) in str(e.value) - - -@pytest.mark.parametrize(("value"), (object(), {"key": "value"})) -def test_multipart_invalid_value(value): - client = httpx.Client(transport=httpx.MockTransport(echo_request_content)) - - data = {"text": value} - files = {"file": io.BytesIO(b"")} - with pytest.raises(TypeError) as e: - client.post("http://127.0.0.1:8000/", data=data, files=files) - assert "Invalid type for value" in str(e.value) - - def test_multipart_file_tuple(): client = httpx.Client(transport=httpx.MockTransport(echo_request_content))