From 6813c86fba477b07adcb2c0578a99387a537568b Mon Sep 17 00:00:00 2001 From: d9pouces Date: Mon, 5 Oct 2026 22:13:18 +0200 Subject: [PATCH] refactor: remove unnecessary noqa comments in user tests and user entry creation Signed-off-by: d9pouces --- id_configurator/users.py | 2 +- tests/test_users.py | 27 +++++++++------------------ 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/id_configurator/users.py b/id_configurator/users.py index eadaa96..89d6ef1 100644 --- a/id_configurator/users.py +++ b/id_configurator/users.py @@ -57,7 +57,7 @@ def parse_passwd(content: str) -> list[PasswdEntry]: except ValueError: continue entries.append( - PasswdEntry(name=fields[0], uid=uid, home=fields[5], shell=fields[6]) # noqa: B604 + PasswdEntry(name=fields[0], uid=uid, home=fields[5], shell=fields[6]) ) return entries diff --git a/tests/test_users.py b/tests/test_users.py index 5f6c144..a6dfd86 100644 --- a/tests/test_users.py +++ b/tests/test_users.py @@ -43,23 +43,17 @@ def test_parse_passwd_skips_malformed_lines() -> None: def test_has_login_shell_true_for_regular_shell() -> None: - entry = PasswdEntry(name="alice", uid=1000, home="/home/alice", shell="/bin/bash") # noqa: B604 + entry = PasswdEntry(name="alice", uid=1000, home="/home/alice", shell="/bin/bash") assert entry.has_login_shell is True def test_has_login_shell_false_for_nologin_sync_or_false() -> None: nologin = PasswdEntry( - name="daemon", - uid=1, - home="/usr/sbin", - shell="/usr/sbin/nologin", # noqa: B604 + name="daemon", uid=1, home="/usr/sbin", shell="/usr/sbin/nologin" ) - sync = PasswdEntry(name="sync", uid=4, home="/bin", shell="/bin/sync") # noqa: B604 + sync = PasswdEntry(name="sync", uid=4, home="/bin", shell="/bin/sync") false_shell = PasswdEntry( - name="nobody", - uid=65534, - home="/nonexistent", - shell="/usr/sbin/false", # noqa: B604 + name="nobody", uid=65534, home="/nonexistent", shell="/usr/sbin/false" ) assert nologin.has_login_shell is False assert sync.has_login_shell is False @@ -67,32 +61,29 @@ def test_has_login_shell_false_for_nologin_sync_or_false() -> None: def test_is_regular_user_true_for_human_account() -> None: - entry = PasswdEntry(name="alice", uid=1000, home="/home/alice", shell="/bin/bash") # noqa: B604 + entry = PasswdEntry(name="alice", uid=1000, home="/home/alice", shell="/bin/bash") assert entry.is_regular_user() is True def test_is_regular_user_true_for_root_despite_uid_zero() -> None: - entry = PasswdEntry(name="root", uid=0, home="/root", shell="/bin/bash") # noqa: B604 + entry = PasswdEntry(name="root", uid=0, home="/root", shell="/bin/bash") assert entry.is_regular_user() is True def test_is_regular_user_false_for_root_with_disabled_shell() -> None: - entry = PasswdEntry(name="root", uid=0, home="/root", shell="/usr/sbin/nologin") # noqa: B604 + entry = PasswdEntry(name="root", uid=0, home="/root", shell="/usr/sbin/nologin") assert entry.is_regular_user() is False def test_is_regular_user_false_for_disabled_shell_despite_high_uid() -> None: entry = PasswdEntry( - name="nobody", - uid=65534, - home="/nonexistent", - shell="/usr/sbin/false", # noqa: B604 + name="nobody", uid=65534, home="/nonexistent", shell="/usr/sbin/false" ) assert entry.is_regular_user() is False def test_is_regular_user_honors_custom_uid_min() -> None: - entry = PasswdEntry(name="svc", uid=500, home="/home/svc", shell="/bin/bash") # noqa: B604 + entry = PasswdEntry(name="svc", uid=500, home="/home/svc", shell="/bin/bash") assert entry.is_regular_user(uid_min=1000) is False assert entry.is_regular_user(uid_min=100) is True