Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SQLAlchemy warning #26

Merged
merged 2 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]
]
Loading