Skip to content

Commit 7b2bd18

Browse files
Remove unneded nonlocal and global declarations (#2866) (#2870)
(cherry picked from commit 83025a6) Co-authored-by: Miguel Grinberg <[email protected]>
1 parent 607f3f6 commit 7b2bd18

File tree

6 files changed

+1
-10
lines changed

6 files changed

+1
-10
lines changed

Diff for: elasticsearch/_async/client/_base.py

-1
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,6 @@ async def _perform_request(
298298
def mimetype_header_to_compat(header: str) -> None:
299299
# Converts all parts of a Accept/Content-Type headers
300300
# from application/X -> application/vnd.elasticsearch+X
301-
nonlocal request_headers
302301
mimetype = request_headers.get(header, None)
303302
if mimetype:
304303
request_headers[header] = _COMPAT_MIMETYPE_RE.sub(

Diff for: elasticsearch/_async/helpers.py

-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ def aiter(x: Union[Iterable[T], AsyncIterable[T]]) -> AsyncIterator[T]:
136136
return x.__aiter__()
137137

138138
async def f() -> AsyncIterable[T]:
139-
nonlocal x
140139
ix: Iterable[T] = x
141140
for item in ix:
142141
yield item

Diff for: elasticsearch/_sync/client/_base.py

-1
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,6 @@ def _perform_request(
298298
def mimetype_header_to_compat(header: str) -> None:
299299
# Converts all parts of a Accept/Content-Type headers
300300
# from application/X -> application/vnd.elasticsearch+X
301-
nonlocal request_headers
302301
mimetype = request_headers.get(header, None)
303302
if mimetype:
304303
request_headers[header] = _COMPAT_MIMETYPE_RE.sub(

Diff for: elasticsearch/_sync/client/utils.py

-3
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ def client_node_configs(
134134

135135
def apply_node_options(node_config: NodeConfig) -> NodeConfig:
136136
"""Needs special handling of headers since .replace() wipes out existing headers"""
137-
nonlocal node_options
138137
headers = node_config.headers.copy() # type: ignore[attr-defined]
139138

140139
headers_to_add = node_options.pop("headers", ())
@@ -343,8 +342,6 @@ def _rewrite_parameters(
343342
def wrapper(api: F) -> F:
344343
@wraps(api)
345344
def wrapped(*args: Any, **kwargs: Any) -> Any:
346-
nonlocal api, body_name, body_fields
347-
348345
# Let's give a nicer error message when users pass positional arguments.
349346
if len(args) >= 2:
350347
raise TypeError(

Diff for: test_elasticsearch/test_server/test_rest_api_spec.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,6 @@ def run_catch(self, catch, exception):
280280
self.last_response = exception.body
281281

282282
def run_skip(self, skip):
283-
global IMPLEMENTED_FEATURES
284-
285283
if "features" in skip:
286284
features = skip["features"]
287285
if not isinstance(features, (tuple, list)):
@@ -437,7 +435,7 @@ def _lookup(self, path):
437435
return value
438436

439437
def _feature_enabled(self, name):
440-
global XPACK_FEATURES, IMPLEMENTED_FEATURES
438+
global XPACK_FEATURES
441439
if XPACK_FEATURES is None:
442440
try:
443441
xinfo = self.client.xpack.info()

Diff for: utils/build-dists.py

-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ def set_tmp_dir():
4242

4343

4444
def run(*argv, expect_exit_code=0):
45-
global tmp_dir
4645
try:
4746
prev_dir = os.getcwd()
4847
if tmp_dir is None:

0 commit comments

Comments
 (0)