refactor: simplify conditional logic

Command: `sourcery review --fix --enable de-morgan .`
This commit is contained in:
barredterra
2023-12-05 11:22:55 +01:00
parent 5da3e532c9
commit eb9ee3f79b
51 changed files with 104 additions and 85 deletions

View File

@@ -185,7 +185,10 @@ class AuthorizationControl(TransactionBase):
# Remove user specific rules from global authorization rules
for r in based_on:
if r in final_based_on and not r in ["Itemwise Discount", "Item Group wise Discount"]:
if r in final_based_on and r not in [
"Itemwise Discount",
"Item Group wise Discount",
]:
final_based_on.remove(r)
# Check for authorization set on particular roles
@@ -213,7 +216,10 @@ class AuthorizationControl(TransactionBase):
# Remove role specific rules from global authorization rules
for r in based_on:
if r in final_based_on and not r in ["Itemwise Discount", "Item Group wise Discount"]:
if r in final_based_on and r not in [
"Itemwise Discount",
"Item Group wise Discount",
]:
final_based_on.remove(r)
# Check for global authorization

View File

@@ -44,7 +44,7 @@ class Department(NestedSet):
def before_rename(self, old, new, merge=False):
# renaming consistency with abbreviation
if not frappe.get_cached_value("Company", self.company, "abbr") in new:
if frappe.get_cached_value("Company", self.company, "abbr") not in new:
new = get_abbreviated_name(new, self.company)
return new

View File

@@ -689,7 +689,7 @@ class EmailDigest(Document):
]
def get_root_type_accounts(self, root_type):
if not root_type in self._accounts:
if root_type not in self._accounts:
self._accounts[root_type] = [
d.name
for d in frappe.db.get_all(

View File

@@ -187,7 +187,7 @@ class Employee(NestedSet):
throw(_("Please enter relieving date."))
def validate_for_enabled_user_id(self, enabled):
if not self.status == "Active":
if self.status != "Active":
return
if enabled is None:

View File

@@ -197,7 +197,7 @@ def add_standard_navbar_items():
for item in erpnext_navbar_items:
current_labels = [item.get("item_label") for item in current_navbar_items]
if not item.get("item_label") in current_labels:
if item.get("item_label") not in current_labels:
navbar_settings.append("help_dropdown", item)
for item in current_navbar_items: