Python code modernization, 3/n (#1157)

* Remove __metaclass__ = type.

for i in $(grep -REl '__metaclass__ = type' plugins/ tests/); do
  sed -e '/^__metaclass__ = type/d' -i $i;
done

* Remove super arguments, and stop inheriting from object.
This commit is contained in:
Felix Fontein
2025-10-10 08:11:58 +02:00
committed by GitHub
parent 741c318b1d
commit e8ec22d3b1
99 changed files with 129 additions and 245 deletions
+6 -6
View File
@@ -140,7 +140,7 @@ class Connection(ConnectionBase):
has_pipelining = True
def __init__(self, play_context, new_stdin, *args, **kwargs):
super(Connection, self).__init__(play_context, new_stdin, *args, **kwargs)
super().__init__(play_context, new_stdin, *args, **kwargs)
# Note: docker supports running as non-root in some configurations.
# (For instance, setting the UNIX socket file to be readable and
@@ -365,7 +365,7 @@ class Connection(ConnectionBase):
def _connect(self, port=None):
"""Connect to the container. Nothing to do"""
super(Connection, self)._connect()
super()._connect()
if not self._connected:
self._set_conn_data()
actual_user = self._get_actual_user()
@@ -380,7 +380,7 @@ class Connection(ConnectionBase):
self._set_conn_data()
super(Connection, self).exec_command(cmd, in_data=in_data, sudoable=sudoable)
super().exec_command(cmd, in_data=in_data, sudoable=sudoable)
local_cmd = self._build_exec_cmd([self._play_context.executable, "-c", cmd])
@@ -490,7 +490,7 @@ class Connection(ConnectionBase):
def put_file(self, in_path, out_path):
"""Transfer a file from local to docker container"""
self._set_conn_data()
super(Connection, self).put_file(in_path, out_path)
super().put_file(in_path, out_path)
display.vvv(f"PUT {in_path} TO {out_path}", host=self.get_option("remote_addr"))
out_path = self._prefix_login_path(out_path)
@@ -535,7 +535,7 @@ class Connection(ConnectionBase):
def fetch_file(self, in_path, out_path):
"""Fetch a file from container to local."""
self._set_conn_data()
super(Connection, self).fetch_file(in_path, out_path)
super().fetch_file(in_path, out_path)
display.vvv(
f"FETCH {in_path} TO {out_path}", host=self.get_option("remote_addr")
)
@@ -602,7 +602,7 @@ class Connection(ConnectionBase):
def close(self):
"""Terminate the connection. Nothing to do for Docker"""
super(Connection, self).close()
super().close()
self._connected = False
def reset(self):
+6 -6
View File
@@ -180,7 +180,7 @@ class Connection(ConnectionBase):
)
def __init__(self, play_context, new_stdin, *args, **kwargs):
super(Connection, self).__init__(play_context, new_stdin, *args, **kwargs)
super().__init__(play_context, new_stdin, *args, **kwargs)
self.client = None
self.ids = dict()
@@ -193,7 +193,7 @@ class Connection(ConnectionBase):
def _connect(self, port=None):
"""Connect to the container. Nothing to do"""
super(Connection, self)._connect()
super()._connect()
if not self._connected:
self.actual_user = self.get_option("remote_user")
display.vvv(
@@ -224,7 +224,7 @@ class Connection(ConnectionBase):
def exec_command(self, cmd, in_data=None, sudoable=False):
"""Run a command on the docker host"""
super(Connection, self).exec_command(cmd, in_data=in_data, sudoable=sudoable)
super().exec_command(cmd, in_data=in_data, sudoable=sudoable)
command = [self._play_context.executable, "-c", to_text(cmd)]
@@ -376,7 +376,7 @@ class Connection(ConnectionBase):
def put_file(self, in_path, out_path):
"""Transfer a file from local to docker container"""
super(Connection, self).put_file(in_path, out_path)
super().put_file(in_path, out_path)
display.vvv(f"PUT {in_path} TO {out_path}", host=self.get_option("remote_addr"))
out_path = self._prefix_login_path(out_path)
@@ -418,7 +418,7 @@ class Connection(ConnectionBase):
def fetch_file(self, in_path, out_path):
"""Fetch a file from container to local."""
super(Connection, self).fetch_file(in_path, out_path)
super().fetch_file(in_path, out_path)
display.vvv(
f"FETCH {in_path} TO {out_path}", host=self.get_option("remote_addr")
)
@@ -446,7 +446,7 @@ class Connection(ConnectionBase):
def close(self):
"""Terminate the connection. Nothing to do for Docker"""
super(Connection, self).close()
super().close()
self._connected = False
def reset(self):
+4 -4
View File
@@ -64,7 +64,7 @@ class Connection(ConnectionBase):
has_pipelining = False
def __init__(self, *args, **kwargs):
super(Connection, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)
self.cwd = None
def _connect(self):
@@ -83,7 +83,7 @@ class Connection(ConnectionBase):
return self
def exec_command(self, cmd, in_data=None, sudoable=True):
super(Connection, self).exec_command(cmd, in_data=in_data, sudoable=sudoable)
super().exec_command(cmd, in_data=in_data, sudoable=sudoable)
display.debug("in nsenter.exec_command()")
@@ -232,7 +232,7 @@ class Connection(ConnectionBase):
return (p.returncode, stdout, stderr)
def put_file(self, in_path, out_path):
super(Connection, self).put_file(in_path, out_path)
super().put_file(in_path, out_path)
in_path = unfrackpath(in_path, basedir=self.cwd)
out_path = unfrackpath(out_path, basedir=self.cwd)
@@ -248,7 +248,7 @@ class Connection(ConnectionBase):
raise AnsibleError(f"failed to transfer file to {out_path}: {e}")
def fetch_file(self, in_path, out_path):
super(Connection, self).fetch_file(in_path, out_path)
super().fetch_file(in_path, out_path)
in_path = unfrackpath(in_path, basedir=self.cwd)
out_path = unfrackpath(out_path, basedir=self.cwd)