Skip to content

Commit 69ebb9e

Browse files
committed
amend according to ruff reports
1 parent ef928e5 commit 69ebb9e

4 files changed

Lines changed: 44 additions & 15 deletions

File tree

irods/access.py

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def __hash__(self):
121121

122122
def normal(self, local_zone=""):
123123
"""
124-
Create a normalized version of the object for comparison in sorting or determining equavalence.
124+
Create a normalized version of the object for comparison in sorting or determining equivalence.
125125
126126
Args:
127127
local_zone: the name of the home zone, if any, in which client user directly authenticates.
@@ -204,27 +204,31 @@ def __repr__(self):
204204

205205
class iRODSAccess(_iRODSAccess_base, metaclass=_Access_LookupMeta):
206206
"""
207-
This class represents an ACL in iRODS and functions as a data container
208-
to convey information to the iRODS server (in the `set` call) and back again to the client
209-
again (in the `get` call).
207+
Represents an ACL in iRODS.
208+
209+
An instance of this class functions as a data container to convey information to the iRODS
210+
server (in the `set` call) and back again to the client again (in the `get` call).
210211
"""
211212

212-
def __init__(self, access_name, path, user_name="", user_zone="", user_type=None):
213+
def __init__(self, access_name, path, user_name="", user_zone="", user_type=None): # noqa: D107
213214
self.codes = self.__class__.codes
214215
self.strings = self.__class__.strings
215216
super().__init__(access_name, path, user_name, user_zone, user_type)
216217

217218

218219
class ACLOperation(iRODSAccess):
219220
"""
220-
Similar to its base class iRODSAccess, this class represents an ACL to be set on an object.
221-
but this class is the counterpart used for the atomic ACLs api. It differs from its base
222-
class in that it has no field to store a logical object path. (For an atomic API call, i
223-
here is always a single logical path to which all operations apply, meaning that it is
224-
appropriate to conveyed that in a location separate from the operations themselves.)
225-
"""
221+
Represents an operation to be performed in iRODS' atomic ACL api.
222+
223+
Similar to its base class, iRODSAccess, this class names an ACL to be set on an object.
224+
It differs, however, in that it forgoes option to store a logical object path. (In the atomic
225+
API call, there is always a single logical path to which all such operations apply, thus
226+
it is appropriate that the path parameter is in a location separate from the operations.)
227+
""" # noqa: D400
226228

227-
def __init__(self, access_name: str, user_name: str = "", user_zone: str = ""):
229+
# ruff: noqa: D105 on
230+
231+
def __init__(self, access_name: str, user_name: str = "", user_zone: str = ""): # noqa: D107
228232
super().__init__(
229233
access_name=access_name,
230234
path="",
@@ -244,6 +248,7 @@ def __eq__(self, other):
244248
)
245249

246250
def __hash__(self):
251+
247252
# Hash in a way consistent with an iRODSAccess having path "".
248253
return hash((
249254
self.access_name,
@@ -266,6 +271,8 @@ def __lt__(self, other):
266271
def __repr__(self):
267272
return f"<ACLOperation {self.access_name} {self.user_name} {self.user_zone}>"
268273

274+
# ruff: noqa: D105 off
275+
269276

270277
(
271278
_synonym_mapping := {
@@ -283,6 +290,9 @@ def __repr__(self):
283290
canonical_permissions = {k: v for k, v in all_permissions.items() if ' ' not in k and k not in ('read', 'write')}
284291

285292

293+
# ruff: noqa: RUF012 N801 SLF001 on
294+
295+
286296
class _deprecated:
287297
class _iRODSAccess_pre_4_3_0(_iRODSAccess_base):
288298
codes = collections.OrderedDict(
@@ -294,7 +304,8 @@ class _iRODSAccess_pre_4_3_0(_iRODSAccess_base):
294304

295305
def __init__(self, *args, **kwargs):
296306
warnings.warn(
297-
"_iRODSAccess_pre_4_3_0 is deprecated and will be removed in a future version. Use iRODSAccess instead.",
307+
"_iRODSAccess_pre_4_3_0 is deprecated and will be removed in "
308+
"a future version. Use iRODSAccess instead.",
298309
DeprecationWarning,
299310
stacklevel=2,
300311
)
@@ -309,3 +320,6 @@ def __getattr__(name):
309320
warnings.warn(f"{name} is deprecated", DeprecationWarning, stacklevel=2)
310321
return _deprecated_names[name]
311322
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
323+
324+
325+
# ruff: noqa: RUF012 N801 SLF001 off

irods/exception.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
# if you're copying these from the docs, you might find the following regex helpful:
22
# s/\(\w\+\)\s\+\(-\d\+\)/class \1(SystemException):\r code = \2/g
33

4-
54
import errno
65
import numbers
76
import os
87
import sys
98
from typing import Dict
109

1110

11+
# ruff: noqa: N801 D101 off
12+
13+
1214
class PycommandsException(Exception):
1315
pass
1416

@@ -2124,3 +2126,6 @@ class PAM_AUTH_PASSWORD_FAILED(PAMException):
21242126

21252127
class PAM_AUTH_PASSWORD_INVALID_TTL(PAMException):
21262128
code = -994000
2129+
2130+
2131+
# ruff: noqa: N801 D101 on

irods/manager/access_manager.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""The access manager is a collection of methods useful for managing iRODS ACLs."""
2+
13
import logging
24
from os.path import basename, dirname
35

@@ -43,6 +45,14 @@ def _to_acl_operation_json(op_input: iRODSAccess):
4345
}
4446

4547
def apply_atomic_operations(self, logical_path: str, *operations, admin=False):
48+
"""
49+
Apply the requested operations atomically to the object at logical_path.
50+
51+
Args:
52+
logical_path: the fully qualified logical path of the target data object or collection.
53+
operations: a sequence of ACLOperation instances.
54+
admin: True if the admin flag should be applied for the Atomic ACLs api call.
55+
"""
4656
request_text = {
4757
"logical_path": logical_path,
4858
"admin_mode": admin,

irods/test/access_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
import sys
55
import unittest
66

7-
from irods.test import helpers
87
from irods.access import ACLOperation, iRODSAccess
98
from irods.collection import iRODSCollection
109
from irods.column import In, Like
1110
from irods.exception import UserDoesNotExist
1211
from irods.models import Collection, DataObject, User
1312
from irods.path import iRODSPath
1413
from irods.session import iRODSSession
14+
from irods.test import helpers
1515
from irods.user import iRODSUser
1616

1717

0 commit comments

Comments
 (0)