Skip to content

Commit 859ee63

Browse files
committed
Enable bandit and pydocstyle; fix docstring warnings
1 parent e805208 commit 859ee63

22 files changed

+142
-325
lines changed

.pydocstyle.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[pydocstyle]
2+
convention = google
3+
inherit = false

netbox_onboarding/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
"""
1+
"""Plugin declaration for netbox_onboarding.
2+
23
(c) 2020 Network To Code
34
Licensed under the Apache License, Version 2.0 (the "License");
45
you may not use this file except in compliance with the License.

netbox_onboarding/api/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""REST API module for netbox_onboarding plugin."""

netbox_onboarding/api/serializers.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
"""
1+
"""Model serializers for the netbox_onboarding REST API.
2+
23
(c) 2020 Network To Code
34
Licensed under the Apache License, Version 2.0 (the "License");
45
you may not use this file except in compliance with the License.
@@ -72,7 +73,7 @@ class OnboardingTaskSerializer(serializers.ModelSerializer):
7273

7374
timeout = serializers.IntegerField(required=False, help_text="Timeout (sec) for device connect")
7475

75-
class Meta:
76+
class Meta: # noqa: D106 "Missing docstring in public nested class"
7677
model = OnboardingTask
7778
fields = [
7879
"id",
@@ -93,6 +94,7 @@ class Meta:
9394
]
9495

9596
def create(self, validated_data):
97+
"""Create an OnboardingTask and enqueue it for processing."""
9698
# Fields are string-type so default to empty (instead of None)
9799
username = validated_data.pop("username", "")
98100
password = validated_data.pop("password", "")

netbox_onboarding/api/urls.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
"""
1+
"""REST API URLs for device onboarding.
2+
23
(c) 2020 Network To Code
34
Licensed under the Apache License, Version 2.0 (the "License");
45
you may not use this file except in compliance with the License.

netbox_onboarding/api/views.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
"""
1+
"""Django REST Framework API views for device onboarding.
2+
23
(c) 2020 Network To Code
34
Licensed under the Apache License, Version 2.0 (the "License");
45
you may not use this file except in compliance with the License.

netbox_onboarding/choices.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
"""
1+
"""ChoiceSet classes for device onboarding.
2+
23
(c) 2020 Network To Code
34
Licensed under the Apache License, Version 2.0 (the "License");
45
you may not use this file except in compliance with the License.

netbox_onboarding/filters.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
"""
1+
"""Filtering logic for OnboardingTask instances.
2+
23
(c) 2020 Network To Code
34
Licensed under the Apache License, Version 2.0 (the "License");
45
you may not use this file except in compliance with the License.
@@ -41,11 +42,12 @@ class OnboardingTaskFilter(NameSlugSearchFilterSet):
4142
field_name="role__slug", queryset=DeviceRole.objects.all(), to_field_name="slug", label="Device Role (slug)",
4243
)
4344

44-
class Meta:
45+
class Meta: # noqa: D106 "Missing docstring in public nested class"
4546
model = OnboardingTask
4647
fields = ["id", "site", "site_id", "platform", "role", "status", "failed_reason"]
4748

4849
def search(self, queryset, name, value):
50+
"""Perform the filtered search."""
4951
if not value.strip():
5052
return queryset
5153
qs_filter = (

netbox_onboarding/forms.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
"""
1+
"""Forms for network device onboarding.
2+
23
(c) 2020 Network To Code
34
Licensed under the Apache License, Version 2.0 (the "License");
45
you may not use this file except in compliance with the License.
@@ -38,7 +39,7 @@ class OnboardingTaskFilterForm(BootstrapMixin, forms.ModelForm):
3839

3940
q = forms.CharField(required=False, label="Search")
4041

41-
class Meta:
42+
class Meta: # noqa: D106 "Missing docstring in public nested class"
4243
model = OnboardingTask
4344
fields = ["q", "site", "platform", "status", "failed_reason"]
4445

@@ -76,6 +77,6 @@ class OnboardingTaskFeedCSVForm(CustomFieldModelCSVForm):
7677
error_messages={"invalid_choice": "DeviceRole not found",},
7778
)
7879

79-
class Meta:
80+
class Meta: # noqa: D106 "Missing docstring in public nested class"
8081
model = OnboardingTask
8182
fields = OnboardingTask.csv_headers

netbox_onboarding/models.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
"""
1+
"""OnboardingTask Django model.
2+
23
(c) 2020 Network To Code
34
Licensed under the Apache License, Version 2.0 (the "License");
45
you may not use this file except in compliance with the License.
@@ -16,9 +17,7 @@
1617

1718

1819
class OnboardingTask(models.Model):
19-
"""
20-
The status of each onboarding Task is tracked in the OnboardingTask table
21-
"""
20+
"""The status of each onboarding Task is tracked in the OnboardingTask table."""
2221

2322
group_id = models.CharField(max_length=255, help_text="CSV Bulk Import Group ID (optional)", blank=True)
2423

@@ -73,5 +72,5 @@ class OnboardingTask(models.Model):
7372
"role",
7473
]
7574

76-
class Meta:
75+
class Meta: # noqa: D106 "missing docstring in public nested class"
7776
ordering = ["created_on"]

0 commit comments

Comments
 (0)