Skip to content

Commit

Permalink
Merge pull request #26 from alan-turing-institute/25-fix-sqlalchemy-w…
Browse files Browse the repository at this point in the history
…arning

Fix SQLAlchemy warning
  • Loading branch information
jemrobinson authored Jan 9, 2025
2 parents 958eb0d + 5a2b393 commit 65825a9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 24 deletions.
26 changes: 14 additions & 12 deletions guacamole_user_sync/postgresql/postgresql_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def assign_users_to_groups(
len(users),
len(groups),
)
user_group_members = []
user_group_members: list[tuple[int, int]] = []
for group in groups:
logger.debug("Working on group '%s'", group.name)
# Get the user_group_id for each group (via looking up the entity_id)
Expand Down Expand Up @@ -120,20 +120,24 @@ def assign_users_to_groups(
user_uid,
)
continue
# Create an entry in the user group member table
user_group_members.append(
GuacamoleUserGroupMember(
user_group_id=user_group_id,
member_entity_id=user_entity_id,
),
)
# Record user/group associations
user_group_members.append((user_group_id, user_entity_id))
# Clear existing assignments then reassign
logger.debug(
"... creating %s user/group assignments.",
len(user_group_members),
)
self.backend.delete(GuacamoleUserGroupMember)
self.backend.add_all(user_group_members)
# Create entries in the user group member table
self.backend.add_all(
[
GuacamoleUserGroupMember(
user_group_id=user_group_id,
member_entity_id=user_entity_id,
)
for user_group_id, user_entity_id in user_group_members
],
)

def ensure_schema(self, schema_version: SchemaVersion) -> None:
try:
Expand Down Expand Up @@ -216,9 +220,7 @@ def update_group_entities(self) -> None:
)
self.backend.add_all(
[
GuacamoleUserGroup(
entity_id=group_entity_id,
)
GuacamoleUserGroup(entity_id=group_entity_id)
for group_entity_id in new_group_entity_ids
],
)
Expand Down
24 changes: 12 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -148,16 +148,16 @@ select = [
"YTT", # flake8-2020
]
ignore = [
"ANN101", # missing-type-self [deprecated]
"ANN102", # missing-type-cls [deprecated]
"D100", # undocumented-public-module
"D102", # undocumented-public-method
"D103", # undocumented-public-function
"D104", # undocumented-public-package
"D105", # undocumented-magic-method
"D107", # undocumented-public-init
"D203", # one-blank-line-before-class [conflicts with D211]
"D213", # multi-line-summary-second-line [conflicts with D212]
"D400", # ends-in-period [conflicts with D415]
"S101", # assert [conflicts with pytest]
"ANN101", # missing-type-self [deprecated]
"ANN102", # missing-type-cls [deprecated]
"D100", # undocumented-public-module
"D102", # undocumented-public-method
"D103", # undocumented-public-function
"D104", # undocumented-public-package
"D105", # undocumented-magic-method
"D107", # undocumented-public-init
"D203", # one-blank-line-before-class [conflicts with D211]
"D213", # multi-line-summary-second-line [conflicts with D212]
"D400", # ends-in-period [conflicts with D415]
"S101", # assert [conflicts with pytest]
]

0 comments on commit 65825a9

Please sign in to comment.