Skip to content

Commit c6078cc

Browse files
committed
Ruff fixes
1 parent bed67a6 commit c6078cc

File tree

1 file changed

+77
-10
lines changed

1 file changed

+77
-10
lines changed

netbox_custom_objects/migrations/0001_initial.py

Lines changed: 77 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,41 @@ class Migration(migrations.Migration):
3838
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False)),
3939
('created', models.DateTimeField(auto_now_add=True, null=True)),
4040
('last_updated', models.DateTimeField(auto_now=True, null=True)),
41-
('custom_field_data', models.JSONField(blank=True, default=dict, encoder=utilities.json.CustomFieldJSONEncoder)),
41+
('custom_field_data', models.JSONField(
42+
blank=True,
43+
default=dict,
44+
encoder=utilities.json.CustomFieldJSONEncoder,
45+
)),
4246
('description', models.CharField(blank=True, max_length=200)),
4347
('comments', models.TextField(blank=True)),
44-
('name', models.CharField(max_length=100, unique=True, validators=[django.core.validators.RegexValidator(message='Only lowercase alphanumeric characters and underscores are allowed.', regex='^[a-z0-9_]+$'), django.core.validators.RegexValidator(flags=re.RegexFlag['IGNORECASE'], inverse_match=True, message='Double underscores are not permitted in custom object object type names.', regex='__')])),
48+
('name', models.CharField(
49+
max_length=100,
50+
unique=True,
51+
validators=[
52+
django.core.validators.RegexValidator(
53+
message='Only lowercase alphanumeric characters and underscores are allowed.',
54+
regex='^[a-z0-9_]+$',
55+
),
56+
django.core.validators.RegexValidator(
57+
flags=re.RegexFlag['IGNORECASE'],
58+
inverse_match=True,
59+
message='Double underscores are not permitted in custom object object type names.',
60+
regex='__',
61+
)
62+
]
63+
)),
4564
('version', models.CharField(blank=True, max_length=10)),
4665
('verbose_name', models.CharField(blank=True, max_length=100)),
4766
('verbose_name_plural', models.CharField(blank=True, max_length=100)),
4867
('slug', models.SlugField(max_length=100, unique=True)),
49-
('object_type', models.OneToOneField(blank=True, editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='custom_object_types', to='core.objecttype')),
68+
('object_type', models.OneToOneField(
69+
blank=True,
70+
editable=False,
71+
null=True,
72+
on_delete=django.db.models.deletion.CASCADE,
73+
related_name='custom_object_types',
74+
to='core.objecttype',
75+
)),
5076
('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
5177
],
5278
options={
@@ -63,7 +89,22 @@ class Migration(migrations.Migration):
6389
('last_updated', models.DateTimeField(auto_now=True, null=True)),
6490
('type', models.CharField(default='text', max_length=50)),
6591
('primary', models.BooleanField(default=False)),
66-
('name', models.CharField(max_length=50, validators=[django.core.validators.RegexValidator(flags=re.RegexFlag['IGNORECASE'], message='Only alphanumeric characters and underscores are allowed.', regex='^[a-z0-9_]+$'), django.core.validators.RegexValidator(flags=re.RegexFlag['IGNORECASE'], inverse_match=True, message='Double underscores are not permitted in custom object field names.', regex='__')])),
92+
('name', models.CharField(
93+
max_length=50,
94+
validators=[
95+
django.core.validators.RegexValidator(
96+
flags=re.RegexFlag['IGNORECASE'],
97+
message='Only alphanumeric characters and underscores are allowed.',
98+
regex='^[a-z0-9_]+$',
99+
),
100+
django.core.validators.RegexValidator(
101+
flags=re.RegexFlag['IGNORECASE'],
102+
inverse_match=True,
103+
message='Double underscores are not permitted in custom object field names.',
104+
regex='__',
105+
)
106+
]
107+
)),
67108
('label', models.CharField(blank=True, max_length=50)),
68109
('group_name', models.CharField(blank=True, max_length=50)),
69110
('description', models.CharField(blank=True, max_length=200)),
@@ -76,14 +117,33 @@ class Migration(migrations.Migration):
76117
('weight', models.PositiveSmallIntegerField(default=100)),
77118
('validation_minimum', models.BigIntegerField(blank=True, null=True)),
78119
('validation_maximum', models.BigIntegerField(blank=True, null=True)),
79-
('validation_regex', models.CharField(blank=True, max_length=500, validators=[utilities.validators.validate_regex])),
120+
('validation_regex', models.CharField(
121+
blank=True,
122+
max_length=500,
123+
validators=[utilities.validators.validate_regex],
124+
)),
80125
('ui_visible', models.CharField(default='always', max_length=50)),
81126
('ui_editable', models.CharField(default='yes', max_length=50)),
82127
('is_cloneable', models.BooleanField(default=False)),
83128
('comments', models.TextField(blank=True)),
84-
('choice_set', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='choices_for_object_type', to='extras.customfieldchoiceset')),
85-
('custom_object_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='fields', to='netbox_custom_objects.customobjecttype')),
86-
('related_object_type', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='core.objecttype')),
129+
('choice_set', models.ForeignKey(
130+
blank=True,
131+
null=True,
132+
on_delete=django.db.models.deletion.PROTECT,
133+
related_name='choices_for_object_type',
134+
to='extras.customfieldchoiceset',
135+
)),
136+
('custom_object_type', models.ForeignKey(
137+
on_delete=django.db.models.deletion.CASCADE,
138+
related_name='fields',
139+
to='netbox_custom_objects.customobjecttype',
140+
)),
141+
('related_object_type', models.ForeignKey(
142+
blank=True,
143+
null=True,
144+
on_delete=django.db.models.deletion.PROTECT,
145+
to='core.objecttype',
146+
)),
87147
],
88148
options={
89149
'verbose_name': 'custom object type field',
@@ -94,10 +154,17 @@ class Migration(migrations.Migration):
94154
),
95155
migrations.AddConstraint(
96156
model_name='customobjecttype',
97-
constraint=models.UniqueConstraint(django.db.models.functions.text.Lower('name'), name='netbox_custom_objects_customobjecttype_name', violation_error_message='A Custom Object Type with this name already exists.'),
157+
constraint=models.UniqueConstraint(
158+
django.db.models.functions.text.Lower('name'),
159+
name='netbox_custom_objects_customobjecttype_name',
160+
violation_error_message='A Custom Object Type with this name already exists.',
161+
),
98162
),
99163
migrations.AddConstraint(
100164
model_name='customobjecttypefield',
101-
constraint=models.UniqueConstraint(fields=('name', 'custom_object_type'), name='netbox_custom_objects_customobjecttypefield_unique_name'),
165+
constraint=models.UniqueConstraint(
166+
fields=('name', 'custom_object_type'),
167+
name='netbox_custom_objects_customobjecttypefield_unique_name',
168+
),
102169
),
103170
]

0 commit comments

Comments
 (0)