Skip to content

Commit 51d8ddb

Browse files
authored
Ruff: Add and autofix B009 (#11950)
1 parent 7a54950 commit 51d8ddb

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

dojo/forms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ class ProductForm(forms.ModelForm):
321321
def __init__(self, *args, **kwargs):
322322
super().__init__(*args, **kwargs)
323323
self.fields["prod_type"].queryset = get_authorized_product_types(Permissions.Product_Type_Add_Product)
324-
if prod_type_id := getattr(kwargs.get("instance", Product()), "prod_type_id"): # we are editing existing instance
324+
if prod_type_id := kwargs.get("instance", Product()).prod_type_id: # we are editing existing instance
325325
self.fields["prod_type"].queryset |= Product_Type.objects.filter(pk=prod_type_id) # even if user does not have permission for any other ProdType we need to add at least assign ProdType to make form submittable (otherwise empty list was here which generated invalid form)
326326

327327
# if this product has findings being asynchronously updated, disable the sla config field

dojo/notifications/helper.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ def _process_notifications(
807807
if alert_only:
808808
logger.debug("sending alert only")
809809

810-
if "alert" in getattr(notifications, event, getattr(notifications, "other")):
810+
if "alert" in getattr(notifications, event, notifications.other):
811811
logger.debug(f"Sending Alert to {notifications.user}")
812812
self._get_manager_instance("alert").send_alert_notification(
813813
event,
@@ -821,7 +821,7 @@ def _process_notifications(
821821
if self.system_settings.enable_slack_notifications and "slack" in getattr(
822822
notifications,
823823
event,
824-
getattr(notifications, "other"),
824+
notifications.other,
825825
):
826826
logger.debug("Sending Slack Notification")
827827
self._get_manager_instance("slack").send_slack_notification(
@@ -833,7 +833,7 @@ def _process_notifications(
833833
if self.system_settings.enable_msteams_notifications and "msteams" in getattr(
834834
notifications,
835835
event,
836-
getattr(notifications, "other"),
836+
notifications.other,
837837
):
838838
logger.debug("Sending MSTeams Notification")
839839
self._get_manager_instance("msteams").send_msteams_notification(
@@ -845,7 +845,7 @@ def _process_notifications(
845845
if self.system_settings.enable_mail_notifications and "mail" in getattr(
846846
notifications,
847847
event,
848-
getattr(notifications, "other"),
848+
notifications.other,
849849
):
850850
logger.debug("Sending Mail Notification")
851851
self._get_manager_instance("mail").send_mail_notification(
@@ -857,7 +857,7 @@ def _process_notifications(
857857
if self.system_settings.enable_webhooks_notifications and "webhooks" in getattr(
858858
notifications,
859859
event,
860-
getattr(notifications, "other"),
860+
notifications.other,
861861
):
862862
logger.debug("Sending Webhooks Notification")
863863
self._get_manager_instance("webhooks").send_webhooks_notification(

dojo/tools/tenable/xml_format.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def safely_get_element_text(self, element):
4646
if element is None:
4747
return None
4848
if hasattr(element, "text"):
49-
element_text = getattr(element, "text")
49+
element_text = element.text
5050
if element_text is None:
5151
return None
5252
if isinstance(element_text, str):

ruff.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ select = [
8585
"FURB",
8686
"DOC202", "DOC403", "DOC502",
8787
"RUF",
88+
"B009",
8889
"B010",
8990
"B033",
9091
"B905",

0 commit comments

Comments
 (0)