Skip to content

Commit

Permalink
[fix] Mypy typing warning
Browse files Browse the repository at this point in the history
  • Loading branch information
zamentur committed Jan 27, 2025
1 parent fbbbc08 commit 1e1e80f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def portal_update(
username, domain, current_user = _get_user_infos(
["givenName", "sn", "cn", "mail", "maildrop", "memberOf"]
)
new_attr_dict = {}
new_attr_dict: dict[str, Any] = {}

if fullname is not None and fullname != current_user["cn"]:
fullname = fullname.strip()
Expand Down
13 changes: 9 additions & 4 deletions src/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ def user_update(
env_dict: dict[str, str] = {"YNH_USER_USERNAME": username}

# Get modifications from arguments
new_attr_dict = {}
new_attr_dict: dict[str, Any] = {}
if firstname:
new_attr_dict["givenName"] = firstname # TODO: Validate
new_attr_dict["cn"] = new_attr_dict["displayName"] = (
Expand Down Expand Up @@ -551,7 +551,9 @@ def user_update(
remove_mailforward = [remove_mailforward]
new_attr_dict["maildrop"] = set(user["maildrop"]) - set(remove_mailforward)

if len(user["maildrop"]) - len(remove_mailforward) != len(new_attr_dict["maildrop"]):
if len(user["maildrop"]) - len(remove_mailforward) != len(
new_attr_dict["maildrop"]
):
raise YunohostValidationError("mail_forward_remove_failed", mail=mail)

if "maildrop" in new_attr_dict:
Expand Down Expand Up @@ -1241,7 +1243,7 @@ def user_group_update(
_ldap_path_extract(p, "uid") for p in group.get("member", [])
]
new_group_members = copy.copy(current_group_members)
new_attr_dict: dict[str, list] = {}
new_attr_dict: dict[str, Any] = {}

# Group permissions
current_group_permissions = [
Expand Down Expand Up @@ -1345,7 +1347,10 @@ def user_group_update(
new_attr_dict["objectClass"] = set(group["objectClass"])
new_attr_dict["objectClass"].add("mailGroup")
else:
new_attr_dict["objectClass"] = set(group["objectClass"]) - {"mailGroup", "mailAccount"}
new_attr_dict["objectClass"] = set(group["objectClass"]) - {
"mailGroup",
"mailAccount",
}

if new_attr_dict:
if not from_import:
Expand Down
1 change: 0 additions & 1 deletion src/utils/ldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,6 @@ def update(self, rdn, attr_dict, new_rdn=False):
dn = f"{rdn},{BASEDN}"
current_entry = self.search(rdn, attrs=None)


# Previously, we used modifyModlist, which directly uses the lib system libldap
# supplied with openldap. Unfortunately, the output of this command was not
# optimal with attributes containing lists (complete deletion then complete
Expand Down

0 comments on commit 1e1e80f

Please sign in to comment.