Skip to content

Commit 4296285

Browse files
Bump ruff and fix type equalvalence checking issues (#93)
1 parent c420494 commit 4296285

File tree

15 files changed

+33
-35
lines changed

15 files changed

+33
-35
lines changed

.github/workflows/lint.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ jobs:
2323
python-version: ["3.12"]
2424
steps:
2525
- uses: actions/checkout@v4
26-
- uses: chartboost/ruff-action@v1
2726
- name: Set up Python ${{ matrix.python-version }}
2827
uses: actions/setup-python@v5
2928
with:

api/models/access_request.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def get_all_possible_request_approvers(access_request: AccessRequest) -> Set[Okt
1515

1616
app_managers = []
1717

18-
if type(access_request.requested_group) == AppGroup:
18+
if type(access_request.requested_group) is AppGroup:
1919
app_managers = get_app_managers(access_request.requested_group.app_id)
2020

2121
return set(group_owners + access_app_owners + app_managers)

api/operations/constraints/check_for_reason.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def execute_for_group(self) -> Tuple[bool, str]:
6464

6565
# If the group is a role group check to see if a reason is required for adding members or owners
6666
# to the associated groups
67-
if type(self.group) == RoleGroup and self.group.is_managed:
67+
if type(self.group) is RoleGroup and self.group.is_managed:
6868
member_groups = [rm.active_group for rm in self.group.active_role_associated_group_member_mappings]
6969
for member_group in member_groups:
7070
require_member_reason = coalesce_constraints(
@@ -92,7 +92,7 @@ def execute_for_group(self) -> Tuple[bool, str]:
9292
return True, ""
9393

9494
def execute_for_role(self) -> Tuple[bool, str]:
95-
if type(self.group) != RoleGroup:
95+
if type(self.group) is not RoleGroup:
9696
return True, ""
9797

9898
if self.invalid_reason(self.reason):

api/operations/constraints/check_for_self_add.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def execute_for_group(self) -> Tuple[bool, str]:
7979

8080
# If the group is a role group check to see if a reason is required for adding members or owners
8181
# to the associated groups
82-
if type(self.group) == RoleGroup and self.group.is_managed:
82+
if type(self.group) is RoleGroup and self.group.is_managed:
8383
member_groups = [rm.active_group for rm in self.group.active_role_associated_group_member_mappings]
8484
for member_group in member_groups:
8585
disallow_self_add_membership = coalesce_constraints(
@@ -112,7 +112,7 @@ def execute_for_role(self) -> Tuple[bool, str]:
112112
if self.current_user is None or AuthorizationHelpers.is_access_admin(self.current_user.id):
113113
return True, ""
114114

115-
if type(self.group) != RoleGroup:
115+
if type(self.group) is not RoleGroup:
116116
return True, ""
117117

118118
# Check to see if the current user is a member of the role,

api/operations/create_access_request.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ def execute(self) -> Optional[AccessRequest]:
8282
# If there are no approvers, try to get the app managers
8383
# or if the only approver is the requester, try to get the app managers
8484
if (
85-
(len(approvers) == 0 and type(self.requested_group) == AppGroup)
85+
(len(approvers) == 0 and type(self.requested_group) is AppGroup)
8686
or (len(approvers) == 1 and approvers[0].id == self.requester.id)
87-
and type(self.requested_group) == AppGroup
87+
and type(self.requested_group) is AppGroup
8888
):
8989
approvers = get_app_managers(self.requested_group.app_id)
9090

api/operations/create_app.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def execute(self) -> App:
129129
owner_app_group = CreateGroup(group=owner_app_group, current_user_id=self.current_user_id).execute()
130130
else:
131131
group_id = existing_owner_group.id
132-
if type(existing_owner_group) != AppGroup:
132+
if type(existing_owner_group) is not AppGroup:
133133
ModifyGroupType(
134134
group=existing_owner_group,
135135
group_changes=AppGroup(app_id=app_id, is_owner=True),
@@ -168,7 +168,7 @@ def execute(self) -> App:
168168
)
169169
existing_app_group_ids_to_update = []
170170
for existing_app_group in other_existing_app_groups:
171-
if type(existing_app_group) == AppGroup:
171+
if type(existing_app_group) is AppGroup:
172172
existing_app_group.app_id = app_id
173173
existing_app_group.is_owner = False
174174
else:
@@ -198,7 +198,7 @@ def execute(self) -> App:
198198
CreateGroup(group=app_group, current_user_id=self.current_user_id).execute()
199199
else:
200200
group_id = existing_group.id
201-
if type(existing_owner_group) != AppGroup:
201+
if type(existing_owner_group) is not AppGroup:
202202
ModifyGroupType(
203203
group=existing_owner_group,
204204
group_changes=AppGroup(app_id=app_id, is_owner=False),

api/operations/create_group.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def execute(self, *, _group: Optional[T] = None) -> T:
4545

4646
# Make sure the app exists if we're creating an app group
4747
if (
48-
type(self.group) == AppGroup
48+
type(self.group) is AppGroup
4949
and App.query.filter(App.id == self.group.app_id).filter(App.deleted_at.is_(None)).first() is None
5050
):
5151
raise ValueError("App for AppGroup does not exist")
@@ -58,7 +58,7 @@ def execute(self, *, _group: Optional[T] = None) -> T:
5858
db.session.commit()
5959

6060
# If this is an app group, add any app tags
61-
if type(self.group) == AppGroup:
61+
if type(self.group) is AppGroup:
6262
app_tag_maps = (
6363
AppTagMap.query.filter(AppTagMap.app_id == self.group.app_id)
6464
.filter(

api/operations/delete_group.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ async def _execute(self) -> None:
4848
okta_tasks = []
4949

5050
# Prevent deletion of the Access owner group
51-
if type(self.group) == AppGroup and self.group.is_owner:
51+
if type(self.group) is AppGroup and self.group.is_owner:
5252
app = App.query.filter(App.id == self.group.app_id).filter(App.deleted_at.is_(None)).first()
5353
if app is not None and app.name == App.ACCESS_APP_RESERVED_NAME:
5454
raise ValueError("Access application owner group cannot be deleted")
@@ -110,7 +110,7 @@ async def _execute(self) -> None:
110110
{RoleGroupMap.ended_at: db.func.now()}, synchronize_session="fetch"
111111
)
112112

113-
if type(self.group) == RoleGroup:
113+
if type(self.group) is RoleGroup:
114114
# End all group memberships via the role grant
115115
OktaUserGroupMember.query.filter(
116116
db.or_(

api/operations/modify_group_type.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,12 @@ def __init__(self, *, group: OktaGroup | str, group_changes: OktaGroup, current_
4040

4141
def execute(self) -> OktaGroup:
4242
# Update group type if it's being modified
43-
# Ignore Ruff because we don't want to include subclasses with an isinstance comparison
44-
if type(self.group) != type(self.group_changes): # noqa: E721
43+
if type(self.group) is not type(self.group_changes):
4544
group_id = self.group.id
4645
old_group_type = self.group.type
4746

4847
# Clean-up the old child table row
49-
if type(self.group) == RoleGroup:
48+
if type(self.group) is RoleGroup:
5049
# End all group attachments to this role and all group memberships via the role grant
5150
active_role_associated_groups = RoleGroupMap.query.filter(
5251
db.or_(
@@ -63,7 +62,7 @@ def execute(self) -> OktaGroup:
6362
db.session.commit()
6463

6564
db.session.execute(delete(RoleGroup.__table__).where(RoleGroup.__table__.c.id == group_id))
66-
elif type(self.group) == AppGroup:
65+
elif type(self.group) is AppGroup:
6766
# Bail if this is the owner group for the app
6867
# which cannot have its type changed
6968
if self.group.is_owner:
@@ -96,7 +95,7 @@ def execute(self) -> OktaGroup:
9695
self.group = OktaGroup.query.filter(OktaGroup.deleted_at.is_(None)).filter(OktaGroup.id == group_id).first()
9796

9897
# Create new child table row
99-
if type(self.group_changes) == RoleGroup:
98+
if type(self.group_changes) is RoleGroup:
10099
# Convert any group memberships and ownerships via a role to direct group memberships and ownerships
101100
active_group_users_from_role = (
102101
OktaUserGroupMember.query.filter(
@@ -153,7 +152,7 @@ def execute(self) -> OktaGroup:
153152
).execute()
154153

155154
db.session.execute(insert(RoleGroup.__table__).values(id=group_id))
156-
elif type(self.group_changes) == AppGroup:
155+
elif type(self.group_changes) is AppGroup:
157156
db.session.execute(
158157
insert(AppGroup.__table__).values(
159158
id=group_id,
@@ -170,7 +169,7 @@ def execute(self) -> OktaGroup:
170169
db.session.expunge_all()
171170

172171
# Add all app tags to this new app group, after we've updated the group type
173-
if type(self.group_changes) == AppGroup:
172+
if type(self.group_changes) is AppGroup:
174173
app_tag_maps = (
175174
AppTagMap.query.options(joinedload(AppTagMap.active_tag))
176175
.filter(

api/operations/modify_group_users.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ async def _execute(self) -> OktaGroup:
206206
)
207207

208208
# For role groups, members to be removed should also be removed from all role associated groups
209-
if type(self.group) == RoleGroup:
209+
if type(self.group) is RoleGroup:
210210
role_associated_groups_mappings = (
211211
RoleGroupMap.query.filter(
212212
db.or_(
@@ -274,7 +274,7 @@ async def _execute(self) -> OktaGroup:
274274
async_tasks.append(asyncio.create_task(okta.async_remove_owner_from_group(self.group.id, owner_id)))
275275

276276
# For role groups, members to be removed should also be removed from all Access-managed role associated groups
277-
if type(self.group) == RoleGroup and self.sync_to_okta:
277+
if type(self.group) is RoleGroup and self.sync_to_okta:
278278
role_associated_groups_mappings = (
279279
RoleGroupMap.query.options(joinedload(RoleGroupMap.active_group))
280280
.join(RoleGroupMap.active_group)
@@ -388,7 +388,7 @@ async def _execute(self) -> OktaGroup:
388388
db.session.add(ownership_to_add)
389389

390390
# For role groups, new members should also be added to all Access-managed role associated groups
391-
if type(self.group) == RoleGroup:
391+
if type(self.group) is RoleGroup:
392392
role_associated_groups_mappings = (
393393
RoleGroupMap.query.options(joinedload(RoleGroupMap.active_group))
394394
.join(RoleGroupMap.active_group)

0 commit comments

Comments
 (0)