Skip to content

[Backport 8.x] Remove unneded nonlocal and global declarations #2870

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion elasticsearch/_async/client/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,6 @@ async def _perform_request(
def mimetype_header_to_compat(header: str) -> None:
# Converts all parts of a Accept/Content-Type headers
# from application/X -> application/vnd.elasticsearch+X
nonlocal request_headers
mimetype = request_headers.get(header, None)
if mimetype:
request_headers[header] = _COMPAT_MIMETYPE_RE.sub(
Expand Down
1 change: 0 additions & 1 deletion elasticsearch/_async/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ def aiter(x: Union[Iterable[T], AsyncIterable[T]]) -> AsyncIterator[T]:
return x.__aiter__()

async def f() -> AsyncIterable[T]:
nonlocal x
ix: Iterable[T] = x
for item in ix:
yield item
Expand Down
1 change: 0 additions & 1 deletion elasticsearch/_sync/client/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,6 @@ def _perform_request(
def mimetype_header_to_compat(header: str) -> None:
# Converts all parts of a Accept/Content-Type headers
# from application/X -> application/vnd.elasticsearch+X
nonlocal request_headers
mimetype = request_headers.get(header, None)
if mimetype:
request_headers[header] = _COMPAT_MIMETYPE_RE.sub(
Expand Down
3 changes: 0 additions & 3 deletions elasticsearch/_sync/client/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ def client_node_configs(

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

headers_to_add = node_options.pop("headers", ())
Expand Down Expand Up @@ -343,8 +342,6 @@ def _rewrite_parameters(
def wrapper(api: F) -> F:
@wraps(api)
def wrapped(*args: Any, **kwargs: Any) -> Any:
nonlocal api, body_name, body_fields

# Let's give a nicer error message when users pass positional arguments.
if len(args) >= 2:
raise TypeError(
Expand Down
4 changes: 1 addition & 3 deletions test_elasticsearch/test_server/test_rest_api_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,6 @@ def run_catch(self, catch, exception):
self.last_response = exception.body

def run_skip(self, skip):
global IMPLEMENTED_FEATURES

if "features" in skip:
features = skip["features"]
if not isinstance(features, (tuple, list)):
Expand Down Expand Up @@ -437,7 +435,7 @@ def _lookup(self, path):
return value

def _feature_enabled(self, name):
global XPACK_FEATURES, IMPLEMENTED_FEATURES
global XPACK_FEATURES
if XPACK_FEATURES is None:
try:
xinfo = self.client.xpack.info()
Expand Down
1 change: 0 additions & 1 deletion utils/build-dists.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def set_tmp_dir():


def run(*argv, expect_exit_code=0):
global tmp_dir
try:
prev_dir = os.getcwd()
if tmp_dir is None:
Expand Down