diff roundup/rest.py @ 8203:ef1333b153e3

chore(ruff): changes to else/elif and nested ifs to reduce nesting When first banch of if clause returns/raises, remove else/elif and inline branch instructions to main flow. Removed nested ifs, change boolean to 'and' expressions for all nested if statements.
author John Rouillard <rouilj@ieee.org>
date Wed, 11 Dec 2024 15:09:44 -0500
parents d5ad7fcb9bf6
children 85d2a04e208a
line wrap: on
line diff
--- a/roundup/rest.py	Wed Dec 11 14:29:19 2024 -0500
+++ b/roundup/rest.py	Wed Dec 11 15:09:44 2024 -0500
@@ -241,8 +241,7 @@
 
     if have_etag_match:  # noqa: SIM103  leave for coverage reports
         return True
-    else:
-        return False
+    return False
 
 
 def obtain_etags(headers, input_payload):
@@ -1591,9 +1590,8 @@
             if attr_name in class_obj.getprops(protected=True):
                 raise AttributeError("Attribute '%s' can not be deleted "
                                      "for class %s." % (attr_name, class_name))
-            else:
-                raise UsageError("Attribute '%s' not valid for class %s." % (
-                    attr_name, class_name))
+            raise UsageError("Attribute '%s' not valid for class %s." % (
+                attr_name, class_name))
         if attr_name in class_obj.get_required_props():
             raise UsageError("Attribute '%s' is required by class %s and can not be deleted." % (
                 attr_name, class_name))
@@ -1764,8 +1762,8 @@
 
         prop = attr_name
         class_obj = self.db.getclass(class_name)
-        if attr_name not in class_obj.getprops(protected=False):
-            if attr_name in class_obj.getprops(protected=True):
+        if (attr_name not in class_obj.getprops(protected=False) and
+            attr_name in class_obj.getprops(protected=True)):
                 raise AttributeError("Attribute '%s' can not be updated "
                                      "for class %s." % (attr_name, class_name))
 
@@ -2127,9 +2125,9 @@
         interval = self.db.config.WEB_API_INTERVAL_IN_SEC
         if calls and interval:
             return RateLimit(calls, timedelta(seconds=interval))
-        else:
-            # disable rate limiting if either parameter is 0
-            return None
+
+        # disable rate limiting if either parameter is 0
+        return None
 
     def handle_apiRateLimitExceeded(self, apiRateLimit):
         """Determine if the rate limit is exceeded.

Roundup Issue Tracker: http://roundup-tracker.org/