Skip to content

Commit d4fd20c

Browse files
kiblikMaffooch
andauthored
Ruff: Add and fix A002 (#11646)
Co-authored-by: Cody Maffucci <46459665+Maffooch@users.noreply.github.com>
1 parent 8912572 commit d4fd20c

File tree

44 files changed

+394
-394
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+394
-394
lines changed

dojo/api_v2/permissions.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,20 @@ def check_post_permission(request, post_model, post_pk, post_permission):
4040

4141
def check_object_permission(
4242
request,
43-
object,
43+
obj,
4444
get_permission,
4545
put_permission,
4646
delete_permission,
4747
post_permission=None,
4848
):
4949
if request.method == "GET":
50-
return user_has_permission(request.user, object, get_permission)
50+
return user_has_permission(request.user, obj, get_permission)
5151
if request.method == "PUT" or request.method == "PATCH":
52-
return user_has_permission(request.user, object, put_permission)
52+
return user_has_permission(request.user, obj, put_permission)
5353
if request.method == "DELETE":
54-
return user_has_permission(request.user, object, delete_permission)
54+
return user_has_permission(request.user, obj, delete_permission)
5555
if request.method == "POST":
56-
return user_has_permission(request.user, object, post_permission)
56+
return user_has_permission(request.user, obj, post_permission)
5757
return False
5858

5959

dojo/api_v2/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2433,7 +2433,7 @@ class UserProfileView(GenericAPIView):
24332433
@action(
24342434
detail=True, methods=["get"], filter_backends=[], pagination_class=None,
24352435
)
2436-
def get(self, request, format=None):
2436+
def get(self, request, _=None):
24372437
user = get_current_user()
24382438
user_contact_info = (
24392439
user.usercontactinfo if hasattr(user, "usercontactinfo") else None

dojo/benchmark/views.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -191,16 +191,16 @@ def score_asvs(product, benchmark_type):
191191

192192

193193
@user_is_authorized(Product, Permissions.Benchmark_Edit, "pid")
194-
def benchmark_view(request, pid, type, cat=None):
194+
def benchmark_view(request, pid, benchmark_type, cat=None):
195195
product = get_object_or_404(Product, id=pid)
196-
benchmark_type = get_object_or_404(Benchmark_Type, id=type)
196+
benchmark_type = get_object_or_404(Benchmark_Type, id=benchmark_type)
197197
benchmark_category = Benchmark_Category.objects.filter(
198-
type=type, enabled=True,
198+
type=benchmark_type, enabled=True,
199199
).order_by("name")
200200

201201
# Add requirements to the product
202202
new_benchmarks = Benchmark_Requirement.objects.filter(
203-
category__type=type, category__type__enabled=True, enabled=True,
203+
category__type=benchmark_type, category__type__enabled=True, enabled=True,
204204
).exclude(
205205
id__in=Benchmark_Product.objects.filter(product=product).values_list(
206206
"control_id", flat=True,
@@ -290,10 +290,10 @@ def benchmark_view(request, pid, type, cat=None):
290290

291291

292292
@user_is_authorized(Product, Permissions.Benchmark_Delete, "pid")
293-
def delete(request, pid, type):
293+
def delete(request, pid, benchmark_type):
294294
product = get_object_or_404(Product, id=pid)
295295
benchmark_product_summary = Benchmark_Product_Summary.objects.filter(
296-
product=product, benchmark_type=type,
296+
product=product, benchmark_type=benchmark_type,
297297
).first()
298298
form = DeleteBenchmarkForm(instance=benchmark_product_summary)
299299

@@ -307,7 +307,7 @@ def delete(request, pid, type):
307307
)
308308
if form.is_valid():
309309
benchmark_product = Benchmark_Product.objects.filter(
310-
product=product, control__category__type=type,
310+
product=product, control__category__type=benchmark_type,
311311
)
312312
benchmark_product.delete()
313313
benchmark_product_summary.delete()

dojo/cred/views.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ def new_cred_finding(request, fid):
583583

584584

585585
@user_is_authorized(Cred_User, Permissions.Credential_Delete, "ttid")
586-
def delete_cred_controller(request, destination_url, id, ttid):
586+
def delete_cred_controller(request, destination_url, elem_id, ttid):
587587
cred = Cred_Mapping.objects.filter(pk=ttid).first()
588588
if request.method == "POST":
589589
tform = CredMappingForm(request.POST, instance=cred)
@@ -637,23 +637,23 @@ def delete_cred_controller(request, destination_url, id, ttid):
637637

638638
if destination_url == "cred":
639639
return HttpResponseRedirect(reverse(destination_url))
640-
return HttpResponseRedirect(reverse(destination_url, args=(id, )))
640+
return HttpResponseRedirect(reverse(destination_url, args=(elem_id, )))
641641
tform = CredMappingForm(instance=cred)
642642

643643
add_breadcrumb(title="Delete Credential", top_level=False, request=request)
644644
product_tab = None
645-
if id:
645+
if elem_id:
646646
product = None
647647
if destination_url == "all_cred_product":
648-
product = get_object_or_404(Product, id=id)
648+
product = get_object_or_404(Product, id=elem_id)
649649
elif destination_url == "view_engagement":
650-
engagement = get_object_or_404(Engagement, id=id)
650+
engagement = get_object_or_404(Engagement, id=elem_id)
651651
product = engagement.product
652652
elif destination_url == "view_test":
653-
test = get_object_or_404(Test, id=id)
653+
test = get_object_or_404(Test, id=elem_id)
654654
product = test.engagement.product
655655
elif destination_url == "view_finding":
656-
finding = get_object_or_404(Finding, id=id)
656+
finding = get_object_or_404(Finding, id=elem_id)
657657
product = finding.test.engagement.product
658658
product_tab = Product_Tab(product, title="Delete Credential Mapping", tab="settings")
659659
return render(request, "dojo/delete_cred_all.html", {

dojo/engagement/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,9 +1540,9 @@ def engagement_ics(request, eid):
15401540
return response
15411541

15421542

1543-
def get_list_index(list, index):
1543+
def get_list_index(full_list, index):
15441544
try:
1545-
element = list[index]
1545+
element = full_list[index]
15461546
except Exception:
15471547
element = None
15481548
return element

dojo/jira_link/helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ def prepare_jira_issue_fields(
766766

767767

768768
def add_jira_issue(obj, *args, **kwargs):
769-
def failure_to_add_message(message: str, exception: Exception, object: Any) -> bool:
769+
def failure_to_add_message(message: str, exception: Exception, _: Any) -> bool:
770770
if exception:
771771
logger.exception(exception)
772772
logger.error(message)

dojo/management/commands/test_celery_decorator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ def handle(self, *args, **options):
4949
# the outside decorator only outside
5050

5151

52-
def test2(clazz, id):
53-
model = clazz.objects.get(id=id)
52+
def test2(clazz, clazz_id):
53+
model = clazz.objects.get(id=clazz_id)
5454
logger.debug(model)
5555

5656

dojo/notes/views.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
logger = logging.getLogger(__name__)
2121

2222

23-
def delete_note(request, id, page, objid):
24-
note = get_object_or_404(Notes, id=id)
23+
def delete_note(request, note_id, page, objid):
24+
note = get_object_or_404(Notes, id=note_id)
2525
reverse_url = None
2626
object_id = None
2727

@@ -64,8 +64,8 @@ def delete_note(request, id, page, objid):
6464
return HttpResponseRedirect(reverse(reverse_url, args=(object_id, )))
6565

6666

67-
def edit_note(request, id, page, objid):
68-
note = get_object_or_404(Notes, id=id)
67+
def edit_note(request, note_id, page, objid):
68+
note = get_object_or_404(Notes, id=note_id)
6969
reverse_url = None
7070
object_id = None
7171

@@ -142,8 +142,8 @@ def edit_note(request, id, page, objid):
142142
})
143143

144144

145-
def note_history(request, id, page, objid):
146-
note = get_object_or_404(Notes, id=id)
145+
def note_history(request, elem_id, page, objid):
146+
note = get_object_or_404(Notes, id=elem_id)
147147
reverse_url = None
148148
object_id = None
149149

dojo/reports/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -650,9 +650,9 @@ def prefetch_related_endpoints_for_report(endpoints):
650650
)
651651

652652

653-
def get_list_index(list, index):
653+
def get_list_index(full_list, index):
654654
try:
655-
element = list[index]
655+
element = full_list[index]
656656
except Exception:
657657
element = None
658658
return element

dojo/settings/settings.dist.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -901,10 +901,10 @@ def generate_url(scheme, double_slashes, user, password, host, port, path, param
901901
# https://djangosaml2.readthedocs.io/contents/setup.html#users-attributes-and-account-linking
902902

903903

904-
def saml2_attrib_map_format(dict):
904+
def saml2_attrib_map_format(din):
905905
dout = {}
906-
for i in dict:
907-
dout[i] = (dict[i],)
906+
for i in din:
907+
dout[i] = (din[i],)
908908
return dout
909909

910910

0 commit comments

Comments
 (0)