[elbe-devel] [PATCH v2 19/66] daemons soap authentication: Fix Pylint

Olivier Dion dion at linutronix.de
Fri Jun 5 19:06:43 CEST 2020


23:4:  R1705: (no-else-return)
106:4: R1705: (no-else-return)

Signed-off-by: Olivier Dion <dion at linutronix.de>
---
 elbepack/daemons/soap/authentication.py | 48 ++++++++++++++++---------
 1 file changed, 32 insertions(+), 16 deletions(-)

diff --git a/elbepack/daemons/soap/authentication.py b/elbepack/daemons/soap/authentication.py
index 6d2850ff..e3e28511 100644
--- a/elbepack/daemons/soap/authentication.py
+++ b/elbepack/daemons/soap/authentication.py
@@ -20,6 +20,15 @@ def authenticated_uid(func):
             @authenticated_uid
             def get_files (self, uid, builddir):
     """
+
+    # Do not edit this code.  Although using *args is tempting here,
+    # it will not work because Spyne is doing introspection on the
+    # function's signature.  I think it would be possible to do
+    # something with func.__code__.replace, but this requires deep
+    # Python's internal knowledges.
+
+    # pylint: disable=function-redefined
+
     if func.__code__.co_argcount == 2:
         @wraps(func)
         def wrapped(self):
@@ -31,7 +40,7 @@ def authenticated_uid(func):
 
             return func(self, uid)
         return wrapped
-    elif func.__code__.co_argcount == 3:
+    if func.__code__.co_argcount == 3:
         @wraps(func)
         def wrapped(self, arg1):
             s = self.transport.req_env['beaker.session']
@@ -42,7 +51,7 @@ def authenticated_uid(func):
 
             return func(self, uid, arg1)
         return wrapped
-    elif func.__code__.co_argcount == 4:
+    if func.__code__.co_argcount == 4:
         @wraps(func)
         def wrapped(self, arg1, arg2):
             s = self.transport.req_env['beaker.session']
@@ -53,7 +62,7 @@ def authenticated_uid(func):
 
             return func(self, uid, arg1, arg2)
         return wrapped
-    elif func.__code__.co_argcount == 5:
+    if func.__code__.co_argcount == 5:
         @wraps(func)
         def wrapped(self, arg1, arg2, arg3):
             s = self.transport.req_env['beaker.session']
@@ -64,7 +73,7 @@ def authenticated_uid(func):
 
             return func(self, uid, arg1, arg2, arg3)
         return wrapped
-    elif func.__code__.co_argcount == 6:
+    if func.__code__.co_argcount == 6:
         @wraps(func)
         def wrapped(self, arg1, arg2, arg3, arg4):
             s = self.transport.req_env['beaker.session']
@@ -75,7 +84,7 @@ def authenticated_uid(func):
 
             return func(self, uid, arg1, arg2, arg3, arg4)
         return wrapped
-    elif func.__code__.co_argcount == 7:
+    if func.__code__.co_argcount == 7:
         @wraps(func)
         def wrapped(self, arg1, arg2, arg3, arg4, arg5):
             # pylint: disable=too-many-arguments
@@ -87,10 +96,9 @@ def authenticated_uid(func):
 
             return func(self, uid, arg1, arg2, arg3, arg4, arg5)
         return wrapped
-    else:
-        raise Exception(
-            "arg count %d not implemented" %
-            func.__code__.co_argcount)
+
+    raise Exception("arg count %d not implemented" %
+                    func.__code__.co_argcount)
 
 
 def authenticated_admin(func):
@@ -103,6 +111,15 @@ def authenticated_admin(func):
             @authenticated_uid
             def get_files (self, uid, builddir):
     """
+
+    # Do not edit this code.  Although using *args is tempting here,
+    # it will not work because Spyne is doing introspection on the
+    # function's signature.  I think it would be possible to do
+    # something with func.__code__.replace, but this requires deep
+    # Python's internal knowledges.
+
+    # pylint: disable=function-redefined
+
     if func.__code__.co_argcount == 1:
         @wraps(func)
         def wrapped(self):
@@ -116,7 +133,7 @@ def authenticated_admin(func):
                 raise SoapElbeNotAuthorized()
             return func(self)
         return wrapped
-    elif func.__code__.co_argcount == 2:
+    if func.__code__.co_argcount == 2:
         @wraps(func)
         def wrapped(self, arg1):
             s = self.transport.req_env['beaker.session']
@@ -130,7 +147,7 @@ def authenticated_admin(func):
 
             return func(self, arg1)
         return wrapped
-    elif func.__code__.co_argcount == 3:
+    if func.__code__.co_argcount == 3:
         @wraps(func)
         def wrapped(self, arg1, arg2):
             s = self.transport.req_env['beaker.session']
@@ -143,7 +160,7 @@ def authenticated_admin(func):
                 raise SoapElbeNotAuthorized()
             return func(self, arg1, arg2)
         return wrapped
-    elif func.__code__.co_argcount == 6:
+    if func.__code__.co_argcount == 6:
         @wraps(func)
         def wrapped(self, arg1, arg2, arg3, arg4, arg5):
             # pylint: disable=too-many-arguments
@@ -157,7 +174,6 @@ def authenticated_admin(func):
                 raise SoapElbeNotAuthorized()
             return func(self, arg1, arg2, arg3, arg4, arg5)
         return wrapped
-    else:
-        raise Exception(
-            "arg count %d not implemented" %
-            func.__code__.co_argcount)
+
+    raise Exception("arg count %d not implemented" %
+                    func.__code__.co_argcount)
-- 
2.27.0




More information about the elbe-devel mailing list