Fix pre-commit

This commit is contained in:
twangboy 2023-07-14 09:05:10 -06:00 committed by Megan Wilhite
parent 1f7ad41df7
commit c9512a1853
2 changed files with 6 additions and 4 deletions

View file

@ -158,13 +158,13 @@ def get_specific_user():
user = get_user()
if salt.utils.platform.is_windows():
if _win_current_user_is_admin():
return "sudo_{}".format(user)
return f"sudo_{user}"
else:
env_vars = ("SUDO_USER",)
if user == "root":
for evar in env_vars:
if evar in os.environ:
return "sudo_{}".format(os.environ[evar])
return f"sudo_{os.environ[evar]}"
return user
@ -182,7 +182,7 @@ def chugid(runas, group=None):
target_pw_gid = grp.getgrnam(group).gr_gid
except KeyError as err:
raise CommandExecutionError(
"Failed to fetch the GID for {}. Error: {}".format(group, err)
f"Failed to fetch the GID for {group}. Error: {err}"
)
else:
target_pw_gid = uinfo.pw_gid

View file

@ -9,7 +9,9 @@ from tests.support.mock import patch
log = logging.getLogger(__name__)
pytestmark = [
pytest.mark.skip_unless_on_linux(reason="Should only run in platforms which have duplicate GID support"),
pytest.mark.skip_unless_on_linux(
reason="Should only run in platforms which have duplicate GID support"
),
]
def test_get_group_dict_with_improper_duplicate_root_group():
with patch("salt.utils.user.get_group_list", return_value=["+", "root"]):