Skip to content

Commit 5a45120

Browse files
AAP-39554 fix black (ansible#690)
# [[AAP-39554](https://issues.redhat.com/browse/AAP-39554)] Fix new version of black breaking linting ## Description <!-- Mandatory: Provide a clear, concise description of the changes and their purpose --> - What is being changed? We are pinning to a version of black, flake8 and isort. We are updating old code that no longer works with the pinned version of black - Why is this change needed? Black released a new version and some old code now needs changes to accommodate its new rules. We are pinning black so that this will not affect us in the future. - How does this change address the issue? With the change to the code, the codebase is now compliant with the new rules for black. Pinning black will mean that we will not automatically get new versions of black so existing code will remain compliant. We will have to manually update black in the future if we want to. ## Type of Change <!-- Mandatory: Check one or more boxes that apply --> - [X] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] Documentation update - [ ] Test update - [X] Refactoring (no functional changes) - [X] Development environment change - [X] Configuration change ## Self-Review Checklist <!-- These items help ensure quality - they complement our automated CI checks --> - [X] I have performed a self-review of my code - [X] I have added relevant comments to complex code sections - [X] I have updated documentation where needed - [X] I have considered the security impact of these changes - [X] I have considered performance implications - [X] I have thought about error handling and edge cases - [X] I have tested the changes in my local environment ## Testing Instructions <!-- Optional for test-only changes. Mandatory for all other changes --> <!-- Must be detailed enough for reviewers to reproduce --> ### Prerequisites <!-- List any specific setup required --> ### Steps to Test 1. 2. 3. ### Expected Results <!-- Describe what should happen after following the steps --> ## Additional Context <!-- Optional but helpful information --> ### Required Actions <!-- Check if changes require work in other areas --> <!-- Remove section if no external actions needed --> - [ ] Requires documentation updates <!-- API docs, feature docs, deployment guides --> - [ ] Requires downstream repository changes <!-- Specify repos: django-ansible-base, eda-server, etc. --> - [ ] Requires infrastructure/deployment changes <!-- CI/CD, installer updates, new services --> - [ ] Requires coordination with other teams <!-- UI team, platform services, infrastructure --> - [ ] Blocked by PR/MR: #XXX <!-- Reference blocking PRs/MRs with brief context --> ### Screenshots/Logs <!-- Add if relevant to demonstrate the changes -->
1 parent 8cf18a7 commit 5a45120

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

pyproject.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,19 +131,19 @@ legacy_tox_ini = """
131131
132132
[testenv:flake8]
133133
deps =
134-
flake8
135-
Flake8-pyproject
134+
flake8==7.1.1
135+
Flake8-pyproject==1.2.3
136136
commands = flake8 {posargs:.}
137137
138138
[testenv:black]
139139
deps =
140-
black
140+
black==25.1.0
141141
allowlist_externals = sh
142142
commands = sh -c 'black --version && black {posargs:.}'
143143
144144
[testenv:isort]
145145
deps =
146-
isort
146+
isort==6.0.0
147147
commands = isort {posargs:.}
148148
"""
149149

requirements/requirements_dev.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
ansible # Used in build process to generate some configs
1+
ansible # Used in build process to generate some configs
2+
black==25.1.0 # Linting tool, if changed update pyproject.toml as well
23
build
34
django==4.2.17
45
django-debug-toolbar
56
django-extensions
67
djangorestframework
78
django-split-settings
9+
flake8==7.1.1 # Linting tool, if changed update pyproject.toml as well
10+
Flake8-pyproject==1.2.3 # Linting tool, if changed update pyproject.toml as well
811
ipython
12+
isort==6.0.0 # Linting tool, if changed update pyproject.toml as well
913
tox
1014
tox-docker
1115
typeguard

test_app/models.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ class LogEntry(models.Model):
170170

171171
class Inventory(models.Model):
172172
"Simple example of a child object, it has a link to its parent organization"
173+
173174
name = models.CharField(max_length=512)
174175
organization = models.ForeignKey(Organization, on_delete=models.CASCADE, null=True, related_name='inventories')
175176
credential = models.ForeignKey('test_app.Credential', on_delete=models.SET_NULL, null=True, related_name='inventories')
@@ -195,6 +196,7 @@ def validate_role_assignment(self, actor, role_definition, **kwargs):
195196

196197
class Credential(models.Model):
197198
"Example of a model that gets used by other models"
199+
198200
name = models.CharField(max_length=512)
199201
organization = models.ForeignKey(Organization, on_delete=models.CASCADE, null=True, related_name='credentials')
200202

@@ -209,28 +211,33 @@ def summary_fields(self):
209211

210212
class InstanceGroup(models.Model):
211213
"Example of an object with no parent object, a root resource, a lone wolf"
214+
212215
name = models.CharField(max_length=512)
213216

214217

215218
class Namespace(models.Model):
216219
"Example of a child object with its own child objects"
220+
217221
name = models.CharField(max_length=64, unique=True, blank=False)
218222
organization = models.ForeignKey(Organization, on_delete=models.CASCADE, related_name='namespaces')
219223

220224

221225
class CollectionImport(models.Model):
222226
"Example of a child of a child object, organization is implied by its namespace"
227+
223228
name = models.CharField(max_length=64, unique=True, blank=False)
224229
namespace = models.ForeignKey(Namespace, on_delete=models.CASCADE, related_name='collections')
225230

226231

227232
class ExampleEvent(models.Model):
228233
"Example of a model which is not registered in permission registry in the first place"
234+
229235
name = models.CharField(max_length=64, unique=True, blank=False)
230236

231237

232238
class Cow(models.Model):
233239
"This model has a special action it can do, which is to give advice"
240+
234241
organization = models.ForeignKey(Organization, on_delete=models.CASCADE, related_name='cows')
235242

236243
class Meta:
@@ -241,6 +248,7 @@ class Meta:
241248

242249
class UUIDModel(models.Model):
243250
"Tests that system works with a model that has a string uuid primary key"
251+
244252
id = models.UUIDField(primary_key=True, default=uuid.uuid4)
245253
organization = models.ForeignKey(Organization, on_delete=models.CASCADE, related_name='uuidmodels')
246254

@@ -285,17 +293,20 @@ class Meta:
285293

286294
class ParentName(models.Model):
287295
"Tests that system works with a parent field name different from parent model name"
296+
288297
my_organization = models.ForeignKey(Organization, on_delete=models.CASCADE, related_name='parentnames')
289298

290299

291300
class PositionModel(models.Model):
292301
"Uses a primary key other than id to test that everything still works"
302+
293303
position = models.BigIntegerField(primary_key=True)
294304
organization = models.ForeignKey(Organization, on_delete=models.CASCADE, related_name='positionmodels')
295305

296306

297307
class WeirdPerm(models.Model):
298308
"Uses a weird permission name"
309+
299310
organization = models.ForeignKey(Organization, on_delete=models.CASCADE, related_name='weirdperms')
300311

301312
class Meta:
@@ -320,6 +331,7 @@ class Meta:
320331

321332
class Original1(NamedCommonModel):
322333
"Registered with the Resource Registry"
334+
323335
pass
324336

325337

@@ -332,6 +344,7 @@ class Meta:
332344

333345
class Original2(NamedCommonModel):
334346
"Not registered"
347+
335348
pass
336349

337350

0 commit comments

Comments
 (0)