Skip to content

Commit 63214b6

Browse files
Fix PLC0415 violations (#3899)
* Fix PLC0415 violations * Update code * Update code --------- Co-authored-by: Arkadii Yakovets <arkadii.yakovets@owasp.org> Co-authored-by: Arkadii Yakovets <2201626+arkid15r@users.noreply.github.com>
1 parent 2fea37a commit 63214b6

116 files changed

Lines changed: 285 additions & 251 deletions

File tree

Some content is hidden

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

backend/apps/ai/common/utils.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ def create_chunks_and_embeddings(
4040
ValueError: If context is None or invalid
4141
4242
"""
43-
from apps.ai.models.chunk import Chunk
44-
4543
try:
4644
last_request_time = datetime.now(UTC) - timedelta(
4745
seconds=DEFAULT_LAST_REQUEST_OFFSET_SECONDS
@@ -94,8 +92,6 @@ def regenerate_chunks_for_context(context: Context):
9492
context (Context): The specific context instance to be updated.
9593
9694
"""
97-
from apps.ai.models.chunk import Chunk
98-
9995
context.chunks.all().delete()
10096
new_chunk_texts = Chunk.split_text(context.content)
10197

backend/apps/ai/models/chunk.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ class Chunk(TimestampedModel):
1313
"""AI Chunk model for storing text chunks with embeddings."""
1414

1515
class Meta:
16+
"""Model options."""
17+
1618
db_table = "ai_chunks"
1719
verbose_name = "Chunk"
1820
unique_together = ("context", "text")

backend/apps/ai/models/context.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ class Context(TimestampedModel):
2222
source = models.CharField(max_length=100, blank=True, default="")
2323

2424
class Meta:
25+
"""Model options."""
26+
2527
db_table = "ai_contexts"
2628
verbose_name = "Context"
2729
unique_together = ("entity_type", "entity_id", "source")

backend/apps/api/models/api_key.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ class ApiKey(models.Model):
1717
"""API key model."""
1818

1919
class Meta:
20+
"""Model options."""
21+
2022
db_table = "api_keys"
2123
verbose_name_plural = "API keys"
2224
ordering = ["-created_at"]

backend/apps/common/management/commands/algolia_update_replicas.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ class Command(BaseCommand):
1010

1111
def handle(self, *_args, **_options) -> None:
1212
"""Update replicas for Algolia indices."""
13-
print("\n Starting replica configuration...")
13+
self.stdout.write("\n Starting replica configuration...\n")
1414
ProjectIndex.configure_replicas()
15-
print("\n Replica have been Successfully created.")
15+
self.stdout.write(self.style.SUCCESS("\n Replicas have been successfully created.\n"))

backend/apps/common/management/commands/algolia_update_synonyms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ class Command(BaseCommand):
1111

1212
def handle(self, *_args, **_options) -> None:
1313
"""Update synonyms for Algolia indices."""
14-
print("\nThe following models synonyms were reindexed:")
14+
self.stdout.write("\nThe following models synonyms were reindexed:")
1515
for index in (IssueIndex, ProjectIndex):
1616
count = index.update_synonyms()
1717
if count:
18-
print(f"{7 * ' '} * {index.index_name.capitalize()} --> {count}")
18+
self.stdout.write(f"{7 * ' '} * {index.index_name.capitalize()} --> {count}")

backend/apps/common/management/commands/dump_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def handle(self, *args, **options):
8686
dump_cmd += [f"--table={table}" for table in tables]
8787
dump_cmd += ["-f", str(output_path)]
8888

89-
run(dump_cmd, check=True, env=env)
89+
run(dump_cmd, check=True, env=env) # noqa: S603
9090
self.stdout.write(self.style.SUCCESS(f"Created dump: {output_path}"))
9191
except CalledProcessError as e:
9292
message = f"Command failed: {e.cmd}"

backend/apps/common/management/commands/purge_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ def handle(self, *_args, **options) -> None:
2929
sql.Identifier(model._meta.db_table)
3030
)
3131
)
32-
print(f"Purged {nest_app}.{model.__name__}")
32+
self.stdout.write(f"Purged {nest_app}.{model.__name__}")

backend/apps/core/models/prompt.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ class Prompt(TimestampedModel):
1515
"""Prompt model."""
1616

1717
class Meta:
18+
"""Model options."""
19+
1820
db_table = "nest_prompts"
1921
verbose_name_plural = "Prompts"
2022

backend/apps/github/management/commands/github_add_related_repositories.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def handle(self, *args, **options) -> None:
4343
projects = []
4444
for idx, project in enumerate(active_projects[offset:]):
4545
prefix = f"{idx + offset + 1} of {active_projects_count}"
46-
print(f"{prefix:<10} {project.owasp_url}")
46+
self.stdout.write(f"{prefix:<10} {project.owasp_url}\n")
4747

4848
repository_urls = project.related_urls.copy()
4949
for repository_url in repository_urls:

0 commit comments

Comments
 (0)