Skip to content

Commit 7de0d7e

Browse files
pquentingithub-actions[bot]
authored andcommitted
Remove deprecation warnings when using body parameter (#2302)
(cherry picked from commit 6ec5c9e)
1 parent ca45614 commit 7de0d7e

File tree

2 files changed

+2
-27
lines changed

2 files changed

+2
-27
lines changed

elasticsearch/_sync/client/utils.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -379,15 +379,6 @@ def wrapped(*args: Any, **kwargs: Any) -> Any:
379379
f"'{body_name}' parameter. See https://github.com/elastic/elasticsearch-py/"
380380
"issues/1698 for more information"
381381
)
382-
383-
warnings.warn(
384-
"The 'body' parameter is deprecated and will be removed "
385-
f"in a future version. Instead use the '{body_name}' parameter. "
386-
"See https://github.com/elastic/elasticsearch-py/issues/1698 "
387-
"for more information",
388-
category=DeprecationWarning,
389-
stacklevel=warn_stacklevel(),
390-
)
391382
kwargs[body_name] = body
392383

393384
elif body_fields:
@@ -396,12 +387,6 @@ def wrapped(*args: Any, **kwargs: Any) -> Any:
396387
"Couldn't merge 'body' with other parameters as it wasn't a mapping. "
397388
"Instead of using 'body' use individual API parameters"
398389
)
399-
warnings.warn(
400-
"The 'body' parameter is deprecated and will be removed "
401-
"in a future version. Instead use individual parameters.",
402-
category=DeprecationWarning,
403-
stacklevel=warn_stacklevel(),
404-
)
405390
_merge_kwargs_no_duplicates(kwargs, body)
406391

407392
if parameter_aliases:

test_elasticsearch/test_client/test_rewrite_parameters.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,18 +87,12 @@ def test_body_name_using_body(self):
8787
api_key=("id", "api_key"), body={"query": {"match_all": {}}}
8888
)
8989

90-
assert len(w) == 2
90+
assert len(w) == 1
9191
assert w[0].category == DeprecationWarning
9292
assert (
9393
str(w[0].message)
9494
== "Passing transport options in the API method is deprecated. Use 'Elasticsearch.options()' instead."
9595
)
96-
assert w[1].category == DeprecationWarning
97-
assert str(w[1].message) == (
98-
"The 'body' parameter is deprecated and will be removed in a "
99-
"future version. Instead use the 'document' parameter. See https://github.com/elastic/elasticsearch-py/issues/1698 "
100-
"for more information"
101-
)
10296

10397
assert self.calls == [
10498
((), {"api_key": ("id", "api_key")}),
@@ -139,16 +133,12 @@ def test_body_fields(self):
139133
api_key=("id", "api_key"), body={"query": {"match_all": {}}}
140134
)
141135

142-
assert len(w) == 2
136+
assert len(w) == 1
143137
assert w[0].category == DeprecationWarning
144138
assert (
145139
str(w[0].message)
146140
== "Passing transport options in the API method is deprecated. Use 'Elasticsearch.options()' instead."
147141
)
148-
assert w[1].category == DeprecationWarning
149-
assert str(w[1].message) == (
150-
"The 'body' parameter is deprecated and will be removed in a future version. Instead use individual parameters."
151-
)
152142

153143
assert self.calls == [
154144
((), {"api_key": ("id", "api_key")}),

0 commit comments

Comments
 (0)