Address no-else-raise.

This commit is contained in:
Felix Fontein 2025-10-11 14:54:20 +02:00
parent 73a0bf93d2
commit e3b07ed6b2
6 changed files with 13 additions and 18 deletions

View File

@ -384,7 +384,6 @@ disable=raw-checker-failed,
consider-using-with,
fixme,
import-error, # TODO figure out why pylint cannot find the module
no-else-raise,
no-else-return,
no-member,
no-name-in-module, # TODO figure out why pylint cannot find the module

View File

@ -159,10 +159,9 @@ class Connection(ConnectionBase):
raise AnsibleConnectionFailure(
f'Could not find container "{remote_addr}" or resource in it ({e})'
)
else:
raise AnsibleConnectionFailure(
f'Could not find container "{remote_addr}" ({e})'
)
raise AnsibleConnectionFailure(
f'Could not find container "{remote_addr}" ({e})'
)
except APIError as e:
if e.response is not None and e.response.status_code == 409:
raise AnsibleConnectionFailure(

View File

@ -91,8 +91,7 @@ class Store:
raise errors.StoreError(
f"{self.program} not installed or not available in PATH"
)
else:
raise errors.StoreError(
f'Unexpected OS error "{e.strerror}", errno={e.errno}'
)
raise errors.StoreError(
f'Unexpected OS error "{e.strerror}", errno={e.errno}'
)
return output

View File

@ -130,7 +130,7 @@ def mkbuildcontext(dockerfile):
with tarfile.open(mode="w", fileobj=f) as t:
if isinstance(dockerfile, io.StringIO):
raise TypeError("Please use io.BytesIO to create in-memory Dockerfiles")
elif isinstance(dockerfile, io.BytesIO):
if isinstance(dockerfile, io.BytesIO):
dfinfo = tarfile.TarInfo("Dockerfile")
dfinfo.size = len(dockerfile.getvalue())
dockerfile.seek(0)

View File

@ -273,12 +273,11 @@ def parse_host(addr, is_win32=False, tls=False):
raise errors.DockerException(
f"Invalid bind address format: no path allowed for this protocol: {addr}"
)
else:
path = parsed_url.path
if proto == "unix" and parsed_url.hostname is not None:
# For legacy reasons, we consider unix://path
# to be valid and equivalent to unix:///path
path = "/".join((parsed_url.hostname, path))
path = parsed_url.path
if proto == "unix" and parsed_url.hostname is not None:
# For legacy reasons, we consider unix://path
# to be valid and equivalent to unix:///path
path = "/".join((parsed_url.hostname, path))
netloc = parsed_url.netloc
if proto in ("tcp", "ssh"):

View File

@ -1047,8 +1047,7 @@ def has_list_changed(new_list, old_list, sort_lists=True, sort_key=None):
if unsorted_list and isinstance(unsorted_list[0], dict):
if not sort_key:
raise ValueError("A sort key was not specified when sorting list")
else:
return sorted(unsorted_list, key=lambda k: k[sort_key])
return sorted(unsorted_list, key=lambda k: k[sort_key])
# Either the list is empty or does not contain dictionaries
try: