]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
tests/system/framework/: fix Python linter issues
authorIker Pedrosa <ipedrosa@redhat.com>
Mon, 1 Sep 2025 13:08:53 +0000 (15:08 +0200)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Wed, 10 Sep 2025 07:56:36 +0000 (09:56 +0200)
Fix issues reported by flake8, pycodestyle, isort, black and mypy.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
tests/system/framework/hosts/shadow.py
tests/system/framework/roles/shadow.py
tests/system/framework/utils/tools.py

index 2a0ca3e5dde01db6cdb1d4f5bce95fa3aa69e59b..29e385a7f106395bbbbef674d21103a68e79468a 100644 (file)
@@ -34,7 +34,7 @@ class ShadowHost(BaseHost, BaseLinuxHost):
         self._backup_path: PurePosixPath | None = None
         """Path to backup files."""
 
-        self._verify_files: [dict[str, str]] = [
+        self._verify_files: list[dict[str, str]] = [
             {"origin": "/etc/passwd", "backup": "passwd"},
             {"origin": "/etc/shadow", "backup": "shadow"},
             {"origin": "/etc/group", "backup": "group"},
@@ -42,9 +42,6 @@ class ShadowHost(BaseHost, BaseLinuxHost):
         ]
         """Files to verify for mismatch."""
 
-        self._features: dict[str, bool] | None = None
-        """Features supported by the host."""
-
     def pytest_setup(self) -> None:
         super().pytest_setup()
 
index e67b192567d9d9887f7680de10933c071e750506..39cbb35b7600fb048847631a7167b51f05caf7bd 100644 (file)
@@ -133,7 +133,9 @@ class Shadow(BaseLinuxRole[ShadowHost]):
         Change user password expiry information.
         """
         args_dict = self._parse_args(args)
-        self.logger.info(f'Changing user password expiry information on user "{args_dict["name"]}" on {self.host.hostname}')
+        self.logger.info(
+            f'Changing user password expiry information on user "{args_dict["name"]}" on {self.host.hostname}'
+        )
         cmd = self.host.conn.run("chage " + args[0], log_level=ProcessLogLevel.Error)
 
         self.host.discard_file("/etc/passwd")
index c03091c4cdd4b3e1c946a7315939dbc7dbe84e10..a2c85cba4b460f513a99ff24a21bbe1dd20f9e82 100644 (file)
@@ -16,7 +16,7 @@ __all__ = [
     "PasswdEntry",
     "ShadowEntry",
     "GroupEntry",
-    "GShadowEntry"
+    "GShadowEntry",
     "InitgroupsEntry",
     "LinuxToolsUtils",
     "KillCommand",
@@ -157,7 +157,16 @@ class PasswdEntry(object):
     Result of ``getent passwd``
     """
 
-    def __init__(self, name: str, password: str, uid: int, gid: int, gecos: str, home: str, shell: str) -> None:
+    def __init__(
+        self,
+        name: str | None,
+        password: str | None,
+        uid: int | None,
+        gid: int | None,
+        gecos: str | None,
+        home: str | None,
+        shell: str | None,
+    ) -> None:
         self.name: str | None = name
         """
         User name.
@@ -168,12 +177,12 @@ class PasswdEntry(object):
         User password.
         """
 
-        self.uid: int = uid
+        self.uid: int | None = uid
         """
         User id.
         """
 
-        self.gid: int = gid
+        self.gid: int | None = gid
         """
         Group id.
         """
@@ -231,14 +240,14 @@ class ShadowEntry(object):
 
     def __init__(
         self,
-        name: str,
-        password: str,
-        last_changed: int,
-        min_days: int,
-        max_days: int,
-        warn_days: int,
-        inactivity_days: int,
-        expiration_date: int,
+        name: str | None,
+        password: str | None,
+        last_changed: int | None,
+        min_days: int | None,
+        max_days: int | None,
+        warn_days: int | None,
+        inactivity_days: int | None,
+        expiration_date: int | None,
     ) -> None:
         self.name: str | None = name
         """
@@ -250,22 +259,22 @@ class ShadowEntry(object):
         User password.
         """
 
-        self.last_changed: int = last_changed
+        self.last_changed: int | None = last_changed
         """
         Last password change.
         """
 
-        self.min_days: int = min_days
+        self.min_days: int | None = min_days
         """
         Minimum number of days before a password change is allowed.
         """
 
-        self.max_days: int = max_days
+        self.max_days: int | None = max_days
         """
         Maximum number of days a password is valid.
         """
 
-        self.warn_days: int = warn_days
+        self.warn_days: int | None = warn_days
         """
         Number of days to warn the user before the password expires.
         """
@@ -321,7 +330,7 @@ class GroupEntry(object):
     Result of ``getent group``
     """
 
-    def __init__(self, name: str, password: str, gid: int, members: list[str]) -> None:
+    def __init__(self, name: str | None, password: str | None, gid: int | None, members: list[str]) -> None:
         self.name: str | None = name
         """
         Group name.
@@ -332,7 +341,7 @@ class GroupEntry(object):
         Group password.
         """
 
-        self.gid: int = gid
+        self.gid: int | None = gid
         """
         Group id.
         """
@@ -377,10 +386,10 @@ class GShadowEntry(object):
 
     def __init__(
         self,
-        name: str,
-        password: str,
-        administrators: str,
-        members: str,
+        name: str | None,
+        password: str | None,
+        administrators: str | None,
+        members: str | None,
     ) -> None:
         self.name: str | None = name
         """
@@ -392,21 +401,18 @@ class GShadowEntry(object):
         Group password.
         """
 
-        self.administrators: int = administrators
+        self.administrators: str | None = administrators
         """
         Group administrators.
         """
 
-        self.members: int = members
+        self.members: str | None = members
         """
         Group members.
         """
 
     def __str__(self) -> str:
-        return (
-            f"({self.name}:{self.password}:{self.administrators}:"
-            f"{self.members})"
-        )
+        return f"({self.name}:{self.password}:{self.administrators}:" f"{self.members})"
 
     def __repr__(self) -> str:
         return str(self)