Skip to content

Commit 3d66c24

Browse files
committed
ruff recommended
1 parent 91bfc5a commit 3d66c24

3 files changed

Lines changed: 36 additions & 43 deletions

File tree

irods/access.py

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@
66

77

88
_ichmod_listed_permissions = (
9-
"own",
10-
"delete_object",
11-
"write",
12-
"modify_object",
13-
"create_object",
14-
"delete_metadata",
15-
"modify_metadata",
16-
"create_metadata",
17-
"read",
18-
"read_object",
19-
"read_metadata",
20-
"null",
21-
)
9+
"own",
10+
"delete_object",
11+
"write",
12+
"modify_object",
13+
"create_object",
14+
"delete_metadata",
15+
"modify_metadata",
16+
"create_metadata",
17+
"read",
18+
"read_object",
19+
"read_metadata",
20+
"null",
21+
)
2222

2323

2424
class _Access_LookupMeta(type):
@@ -93,16 +93,11 @@ def __init__(self, access_name, path, user_name="", user_zone="", user_type=None
9393
self.user_type = user_type
9494

9595
def __lt__(self, other):
96-
return (
97-
self.access_name,
98-
self.user_name,
99-
self.user_zone,
100-
iRODSPath(self.path)
101-
) < (
96+
return (self.access_name, self.user_name, self.user_zone, iRODSPath(self.path)) < (
10297
other.access_name,
10398
other.user_name,
10499
other.user_zone,
105-
iRODSPath(other.path)
100+
iRODSPath(other.path),
106101
)
107102

108103
def __eq__(self, other):
@@ -142,8 +137,7 @@ def __repr__(self):
142137

143138

144139
class ACLOperation(iRODSAccess):
145-
146-
def __init__(self, access_name: str, user_name: str="", user_zone: str=""):
140+
def __init__(self, access_name: str, user_name: str = "", user_zone: str = ""):
147141
super().__init__(
148142
access_name=access_name,
149143
path="",
@@ -177,17 +171,19 @@ def __repr__(self):
177171
return f"<ACLOperation {self.access_name} {self.user_name} {self.user_zone}>"
178172

179173

180-
(_ichmod_synonym_mapping := {
181-
# syn : canonical
182-
"write": "modify_object",
183-
"read": "read_object"
184-
}).update(
185-
(key.replace("_"," "),key) for key in iRODSAccess.codes.keys())
174+
(
175+
_ichmod_synonym_mapping := {
176+
# syn : canonical
177+
"write": "modify_object",
178+
"read": "read_object",
179+
}
180+
).update((key.replace("_", " "), key) for key in iRODSAccess.codes.keys())
186181

187182

188-
all_permissions = { **iRODSAccess.codes,
189-
**{key:iRODSAccess.codes[_ichmod_synonym_mapping[key]]
190-
for key in _ichmod_synonym_mapping}}
183+
all_permissions = {
184+
**iRODSAccess.codes,
185+
**{key: iRODSAccess.codes[_ichmod_synonym_mapping[key]] for key in _ichmod_synonym_mapping},
186+
}
191187

192188

193189
class _iRODSAccess_pre_4_3_0(iRODSAccess):

irods/manager/access_manager.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,19 @@ def users_by_ids(session, ids=()):
3737

3838

3939
class AccessManager(Manager):
40-
4140
@staticmethod
4241
def _to_acl_operation_json(op_input: iRODSAccess):
4342
return {
4443
"acl": op_input.access_name,
4544
"entity_name": op_input.user_name,
46-
**(
47-
{} if not (z := op_input.user_zone)
48-
else {"zone": z}
49-
)
45+
**({} if not (z := op_input.user_zone) else {"zone": z}),
5046
}
5147

52-
def apply_atomic_operations(self, logical_path : str, *operations, admin=False):
48+
def apply_atomic_operations(self, logical_path: str, *operations, admin=False):
5349
request_text = {
5450
"logical_path": logical_path,
5551
"admin_mode": admin,
56-
"operations": [self._to_acl_operation_json(op) for op in operations]
52+
"operations": [self._to_acl_operation_json(op) for op in operations],
5753
}
5854

5955
with self.sess.pool.get_connection() as conn:

irods/test/access_test.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -501,17 +501,17 @@ def test_atomic_acls_505(self):
501501
ses = self.sess
502502
zone = user1 = user2 = user3 = group = None
503503
try:
504-
zone = ses.zones.create("twilight","remote")
504+
zone = ses.zones.create("twilight", "remote")
505505
user1 = ses.users.create("test_user_505", "rodsuser")
506506
user2 = ses.users.create("rod_serling_505#twilight", "rodsuser")
507507
user3 = ses.users.create("local_test_user_505", "rodsuser")
508508
group = ses.groups.create("test_group_505")
509509
ses.acls.apply_atomic_operations(
510510
self.coll_path,
511-
a1:=ACLOperation("write", user1.name, user1.zone),
512-
a2:=ACLOperation("read", user2.name, user2.zone),
513-
a3:=ACLOperation("read", user3.name, user3.zone),
514-
a4:=ACLOperation("read", group.name),
511+
a1 := ACLOperation("write", user1.name, user1.zone),
512+
a2 := ACLOperation("read", user2.name, user2.zone),
513+
a3 := ACLOperation("read", user3.name, user3.zone),
514+
a4 := ACLOperation("read", group.name),
515515
)
516516

517517
normalize = lambda access: access.copy(decanonicalize=True, implied_zone=ses.zone)
@@ -536,6 +536,7 @@ def test_atomic_acls_505(self):
536536
if zone:
537537
zone.remove()
538538

539+
539540
if __name__ == "__main__":
540541
# let the tests find the parent irods lib
541542
sys.path.insert(0, os.path.abspath("../.."))

0 commit comments

Comments
 (0)