Skip to content

Commit 343a4af

Browse files
Closes #18022: Extend linter (ruff) to enforce line length limit (120 chars) (#18067)
* Enable E501 rule * Configure ruff formatter * Reformat migration files to fix line length violations * Fix various E501 errors * Move table template code to template_code.py & ignore E501 errors * Reformat raw SQL
1 parent f08e36e commit 343a4af

File tree

200 files changed

+5942
-1684
lines changed

Some content is hidden

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

200 files changed

+5942
-1684
lines changed

netbox/circuits/api/serializers_/circuits.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ class CircuitCircuitTerminationSerializer(WritableNestedSerializer):
5959
class Meta:
6060
model = CircuitTermination
6161
fields = [
62-
'id', 'url', 'display_url', 'display', 'termination_type', 'termination_id', 'termination', 'provider_network', 'port_speed', 'upstream_speed',
63-
'xconnect_id', 'description',
62+
'id', 'url', 'display_url', 'display', 'termination_type', 'termination_id', 'termination',
63+
'provider_network', 'port_speed', 'upstream_speed', 'xconnect_id', 'description',
6464
]
6565

6666
@extend_schema_field(serializers.JSONField(allow_null=True))
@@ -138,9 +138,10 @@ class CircuitTerminationSerializer(NetBoxModelSerializer, CabledObjectSerializer
138138
class Meta:
139139
model = CircuitTermination
140140
fields = [
141-
'id', 'url', 'display_url', 'display', 'circuit', 'term_side', 'termination_type', 'termination_id', 'termination', 'provider_network', 'port_speed',
142-
'upstream_speed', 'xconnect_id', 'pp_info', 'description', 'mark_connected', 'cable', 'cable_end',
143-
'link_peers', 'link_peers_type', 'tags', 'custom_fields', 'created', 'last_updated', '_occupied',
141+
'id', 'url', 'display_url', 'display', 'circuit', 'term_side', 'termination_type', 'termination_id',
142+
'termination', 'provider_network', 'port_speed', 'upstream_speed', 'xconnect_id', 'pp_info', 'description',
143+
'mark_connected', 'cable', 'cable_end', 'link_peers', 'link_peers_type', 'tags', 'custom_fields', 'created',
144+
'last_updated', '_occupied',
144145
]
145146
brief_fields = ('id', 'url', 'display', 'circuit', 'term_side', 'description', 'cable', '_occupied')
146147

netbox/circuits/filtersets.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,9 @@ class CircuitFilterSet(NetBoxModelFilterSet, TenancyFilterSet, ContactModelFilte
241241

242242
class Meta:
243243
model = Circuit
244-
fields = ('id', 'cid', 'description', 'install_date', 'termination_date', 'commit_rate', 'distance', 'distance_unit')
244+
fields = (
245+
'id', 'cid', 'description', 'install_date', 'termination_date', 'commit_rate', 'distance', 'distance_unit',
246+
)
245247

246248
def search(self, queryset, name, value):
247249
if not value.strip():
@@ -336,8 +338,8 @@ class CircuitTerminationFilterSet(NetBoxModelFilterSet, CabledObjectFilterSet):
336338
class Meta:
337339
model = CircuitTermination
338340
fields = (
339-
'id', 'termination_id', 'term_side', 'port_speed', 'upstream_speed', 'xconnect_id', 'description', 'mark_connected',
340-
'pp_info', 'cable_end',
341+
'id', 'termination_id', 'term_side', 'port_speed', 'upstream_speed', 'xconnect_id', 'description',
342+
'mark_connected', 'pp_info', 'cable_end',
341343
)
342344

343345
def search(self, queryset, name, value):

netbox/circuits/forms/filtersets.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,10 @@ class CircuitFilterForm(TenancyFilterForm, ContactModelFilterForm, NetBoxModelFi
121121
fieldsets = (
122122
FieldSet('q', 'filter_id', 'tag'),
123123
FieldSet('provider_id', 'provider_account_id', 'provider_network_id', name=_('Provider')),
124-
FieldSet('type_id', 'status', 'install_date', 'termination_date', 'commit_rate', 'distance', 'distance_unit', name=_('Attributes')),
124+
FieldSet(
125+
'type_id', 'status', 'install_date', 'termination_date', 'commit_rate', 'distance', 'distance_unit',
126+
name=_('Attributes')
127+
),
125128
FieldSet('region_id', 'site_group_id', 'site_id', name=_('Location')),
126129
FieldSet('tenant_group_id', 'tenant_id', name=_('Tenant')),
127130
FieldSet('contact', 'contact_role', 'contact_group', name=_('Contacts')),

netbox/circuits/migrations/0001_squashed.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55

66

77
class Migration(migrations.Migration):
8-
98
initial = True
109

11-
dependencies = [
12-
]
10+
dependencies = []
1311

1412
replaces = [
1513
('circuits', '0001_initial'),
@@ -98,7 +96,12 @@ class Migration(migrations.Migration):
9896
('name', models.CharField(max_length=100)),
9997
('description', models.CharField(blank=True, max_length=200)),
10098
('comments', models.TextField(blank=True)),
101-
('provider', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='networks', to='circuits.provider')),
99+
(
100+
'provider',
101+
models.ForeignKey(
102+
on_delete=django.db.models.deletion.PROTECT, related_name='networks', to='circuits.provider'
103+
),
104+
),
102105
],
103106
options={
104107
'ordering': ('provider', 'name'),

netbox/circuits/migrations/0002_squashed_0029.py

+59-12
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55

66
class Migration(migrations.Migration):
7-
87
dependencies = [
98
('dcim', '0001_initial'),
109
('contenttypes', '0002_remove_content_type_name'),
@@ -58,32 +57,56 @@ class Migration(migrations.Migration):
5857
migrations.AddField(
5958
model_name='circuittermination',
6059
name='_cable_peer_type',
61-
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='contenttypes.contenttype'),
60+
field=models.ForeignKey(
61+
blank=True,
62+
null=True,
63+
on_delete=django.db.models.deletion.SET_NULL,
64+
related_name='+',
65+
to='contenttypes.contenttype',
66+
),
6267
),
6368
migrations.AddField(
6469
model_name='circuittermination',
6570
name='cable',
66-
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='dcim.cable'),
71+
field=models.ForeignKey(
72+
blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='dcim.cable'
73+
),
6774
),
6875
migrations.AddField(
6976
model_name='circuittermination',
7077
name='circuit',
71-
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='terminations', to='circuits.circuit'),
78+
field=models.ForeignKey(
79+
on_delete=django.db.models.deletion.CASCADE, related_name='terminations', to='circuits.circuit'
80+
),
7281
),
7382
migrations.AddField(
7483
model_name='circuittermination',
7584
name='provider_network',
76-
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='circuit_terminations', to='circuits.providernetwork'),
85+
field=models.ForeignKey(
86+
blank=True,
87+
null=True,
88+
on_delete=django.db.models.deletion.PROTECT,
89+
related_name='circuit_terminations',
90+
to='circuits.providernetwork',
91+
),
7792
),
7893
migrations.AddField(
7994
model_name='circuittermination',
8095
name='site',
81-
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='circuit_terminations', to='dcim.site'),
96+
field=models.ForeignKey(
97+
blank=True,
98+
null=True,
99+
on_delete=django.db.models.deletion.PROTECT,
100+
related_name='circuit_terminations',
101+
to='dcim.site',
102+
),
82103
),
83104
migrations.AddField(
84105
model_name='circuit',
85106
name='provider',
86-
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='circuits', to='circuits.provider'),
107+
field=models.ForeignKey(
108+
on_delete=django.db.models.deletion.PROTECT, related_name='circuits', to='circuits.provider'
109+
),
87110
),
88111
migrations.AddField(
89112
model_name='circuit',
@@ -93,26 +116,50 @@ class Migration(migrations.Migration):
93116
migrations.AddField(
94117
model_name='circuit',
95118
name='tenant',
96-
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='circuits', to='tenancy.tenant'),
119+
field=models.ForeignKey(
120+
blank=True,
121+
null=True,
122+
on_delete=django.db.models.deletion.PROTECT,
123+
related_name='circuits',
124+
to='tenancy.tenant',
125+
),
97126
),
98127
migrations.AddField(
99128
model_name='circuit',
100129
name='termination_a',
101-
field=models.ForeignKey(blank=True, editable=False, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='circuits.circuittermination'),
130+
field=models.ForeignKey(
131+
blank=True,
132+
editable=False,
133+
null=True,
134+
on_delete=django.db.models.deletion.SET_NULL,
135+
related_name='+',
136+
to='circuits.circuittermination',
137+
),
102138
),
103139
migrations.AddField(
104140
model_name='circuit',
105141
name='termination_z',
106-
field=models.ForeignKey(blank=True, editable=False, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='circuits.circuittermination'),
142+
field=models.ForeignKey(
143+
blank=True,
144+
editable=False,
145+
null=True,
146+
on_delete=django.db.models.deletion.SET_NULL,
147+
related_name='+',
148+
to='circuits.circuittermination',
149+
),
107150
),
108151
migrations.AddField(
109152
model_name='circuit',
110153
name='type',
111-
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='circuits', to='circuits.circuittype'),
154+
field=models.ForeignKey(
155+
on_delete=django.db.models.deletion.PROTECT, related_name='circuits', to='circuits.circuittype'
156+
),
112157
),
113158
migrations.AddConstraint(
114159
model_name='providernetwork',
115-
constraint=models.UniqueConstraint(fields=('provider', 'name'), name='circuits_providernetwork_provider_name'),
160+
constraint=models.UniqueConstraint(
161+
fields=('provider', 'name'), name='circuits_providernetwork_provider_name'
162+
),
116163
),
117164
migrations.AlterUniqueTogether(
118165
name='providernetwork',

netbox/circuits/migrations/0003_squashed_0037.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66

77
class Migration(migrations.Migration):
8-
98
replaces = [
109
('circuits', '0003_extend_tag_support'),
1110
('circuits', '0004_rename_cable_peer'),
@@ -14,7 +13,7 @@ class Migration(migrations.Migration):
1413
('circuits', '0034_created_datetimefield'),
1514
('circuits', '0035_provider_asns'),
1615
('circuits', '0036_circuit_termination_date_tags_custom_fields'),
17-
('circuits', '0037_new_cabling_models')
16+
('circuits', '0037_new_cabling_models'),
1817
]
1918

2019
dependencies = [

netbox/circuits/migrations/0038_squashed_0042.py

+35-10
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66

77

88
class Migration(migrations.Migration):
9-
109
replaces = [
1110
('circuits', '0038_cabling_cleanup'),
1211
('circuits', '0039_unique_constraints'),
1312
('circuits', '0040_provider_remove_deprecated_fields'),
1413
('circuits', '0041_standardize_description_comments'),
15-
('circuits', '0042_provideraccount')
14+
('circuits', '0042_provideraccount'),
1615
]
1716

1817
dependencies = [
@@ -51,11 +50,15 @@ class Migration(migrations.Migration):
5150
),
5251
migrations.AddConstraint(
5352
model_name='circuittermination',
54-
constraint=models.UniqueConstraint(fields=('circuit', 'term_side'), name='circuits_circuittermination_unique_circuit_term_side'),
53+
constraint=models.UniqueConstraint(
54+
fields=('circuit', 'term_side'), name='circuits_circuittermination_unique_circuit_term_side'
55+
),
5556
),
5657
migrations.AddConstraint(
5758
model_name='providernetwork',
58-
constraint=models.UniqueConstraint(fields=('provider', 'name'), name='circuits_providernetwork_unique_provider_name'),
59+
constraint=models.UniqueConstraint(
60+
fields=('provider', 'name'), name='circuits_providernetwork_unique_provider_name'
61+
),
5962
),
6063
migrations.RemoveField(
6164
model_name='provider',
@@ -84,12 +87,20 @@ class Migration(migrations.Migration):
8487
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False)),
8588
('created', models.DateTimeField(auto_now_add=True, null=True)),
8689
('last_updated', models.DateTimeField(auto_now=True, null=True)),
87-
('custom_field_data', models.JSONField(blank=True, default=dict, encoder=utilities.json.CustomFieldJSONEncoder)),
90+
(
91+
'custom_field_data',
92+
models.JSONField(blank=True, default=dict, encoder=utilities.json.CustomFieldJSONEncoder),
93+
),
8894
('description', models.CharField(blank=True, max_length=200)),
8995
('comments', models.TextField(blank=True)),
9096
('account', models.CharField(max_length=100)),
9197
('name', models.CharField(blank=True, max_length=100)),
92-
('provider', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='accounts', to='circuits.provider')),
98+
(
99+
'provider',
100+
models.ForeignKey(
101+
on_delete=django.db.models.deletion.PROTECT, related_name='accounts', to='circuits.provider'
102+
),
103+
),
93104
('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
94105
],
95106
options={
@@ -98,11 +109,17 @@ class Migration(migrations.Migration):
98109
),
99110
migrations.AddConstraint(
100111
model_name='provideraccount',
101-
constraint=models.UniqueConstraint(condition=models.Q(('name', ''), _negated=True), fields=('provider', 'name'), name='circuits_provideraccount_unique_provider_name'),
112+
constraint=models.UniqueConstraint(
113+
condition=models.Q(('name', ''), _negated=True),
114+
fields=('provider', 'name'),
115+
name='circuits_provideraccount_unique_provider_name',
116+
),
102117
),
103118
migrations.AddConstraint(
104119
model_name='provideraccount',
105-
constraint=models.UniqueConstraint(fields=('provider', 'account'), name='circuits_provideraccount_unique_provider_account'),
120+
constraint=models.UniqueConstraint(
121+
fields=('provider', 'account'), name='circuits_provideraccount_unique_provider_account'
122+
),
106123
),
107124
migrations.RemoveField(
108125
model_name='provider',
@@ -111,7 +128,13 @@ class Migration(migrations.Migration):
111128
migrations.AddField(
112129
model_name='circuit',
113130
name='provider_account',
114-
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='circuits', to='circuits.provideraccount'),
131+
field=models.ForeignKey(
132+
blank=True,
133+
null=True,
134+
on_delete=django.db.models.deletion.PROTECT,
135+
related_name='circuits',
136+
to='circuits.provideraccount',
137+
),
115138
preserve_default=False,
116139
),
117140
migrations.AlterModelOptions(
@@ -120,6 +143,8 @@ class Migration(migrations.Migration):
120143
),
121144
migrations.AddConstraint(
122145
model_name='circuit',
123-
constraint=models.UniqueConstraint(fields=('provider_account', 'cid'), name='circuits_circuit_unique_provideraccount_cid'),
146+
constraint=models.UniqueConstraint(
147+
fields=('provider_account', 'cid'), name='circuits_circuit_unique_provideraccount_cid'
148+
),
124149
),
125150
]

netbox/circuits/migrations/0044_circuit_groups.py

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66

77
class Migration(migrations.Migration):
8-
98
dependencies = [
109
('circuits', '0043_circuittype_color'),
1110
('extras', '0119_notifications'),

netbox/circuits/migrations/0045_circuit_distance.py

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55

66
class Migration(migrations.Migration):
7-
87
dependencies = [
98
('circuits', '0044_circuit_groups'),
109
]

netbox/circuits/migrations/0046_charfield_null_choices.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ def set_null_values(apps, schema_editor):
1515

1616

1717
class Migration(migrations.Migration):
18-
1918
dependencies = [
2019
('circuits', '0045_circuit_distance'),
2120
]
@@ -36,8 +35,5 @@ class Migration(migrations.Migration):
3635
name='cable_end',
3736
field=models.CharField(blank=True, max_length=1, null=True),
3837
),
39-
migrations.RunPython(
40-
code=set_null_values,
41-
reverse_code=migrations.RunPython.noop
42-
),
38+
migrations.RunPython(code=set_null_values, reverse_code=migrations.RunPython.noop),
4339
]

0 commit comments

Comments
 (0)