Skip to content

Commit

Permalink
Remove deprecated using of data parameter.
Browse files Browse the repository at this point in the history
  • Loading branch information
T-256 committed Sep 26, 2024
1 parent 5766bf5 commit fdc7d27
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## Unreleased

* The deprecated using of `data` argument now been removed.
* The deprecated `proxies` argument has now been removed.
* The deprecated `app` argument has now been removed.
* The `URL.raw` property has now been removed.
Expand Down
3 changes: 1 addition & 2 deletions docs/compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ And using `data=...` to send form data:
httpx.post(..., data={"message": "Hello, world"})
```

Using the `data=<text/byte content>` will raise a deprecation warning,
and is expected to be fully removed with the HTTPX 1.0 release.
Unlike `requests`, Using it as `data=<text/byte content>` wont work.

## Upload files

Expand Down
14 changes: 0 additions & 14 deletions httpx/_content.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
from __future__ import annotations

import inspect
import warnings
from json import dumps as json_dumps
from typing import (
Any,
AsyncIterable,
AsyncIterator,
Iterable,
Iterator,
Mapping,
)
from urllib.parse import urlencode

Expand Down Expand Up @@ -192,18 +190,6 @@ def encode_request(
Handles encoding the given `content`, `data`, `files`, and `json`,
returning a two-tuple of (<headers>, <stream>).
"""
if data is not None and not isinstance(data, Mapping):
# We prefer to separate `content=<bytes|str|byte iterator|bytes aiterator>`
# for raw request content, and `data=<form data>` for url encoded or
# multipart form content.
#
# However for compat with requests, we *do* still support
# `data=<bytes...>` usages. We deal with that case here, treating it
# as if `content=<...>` had been supplied instead.
message = "Use 'content=<...>' to upload raw bytes/text content."
warnings.warn(message, DeprecationWarning)
return encode_content(data)

if content is not None:
return encode_content(content)
elif files:
Expand Down

0 comments on commit fdc7d27

Please # to comment.