From 1d80283efab571fc2cf6664b30300e358f46640c Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Fri, 6 Feb 2026 10:28:24 -0500 Subject: [PATCH] Iterate over the file object Since the file is being iterated over already, calling readlines() is unnecessary. It also increases memory usage by reading the file into memory and then iterating over that. --- lib/ansible/modules/user.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/modules/user.py b/lib/ansible/modules/user.py index ebc67896bf7..1f3b0c4e306 100644 --- a/lib/ansible/modules/user.py +++ b/lib/ansible/modules/user.py @@ -3140,7 +3140,7 @@ class BusyBox(User): with open("/etc/shells", "r") as f: shells = [ shell - for shell in (line.strip() for line in f.readlines()) + for shell in (line.strip() for line in f) if shell and not shell.startswith("#") ]