Skip to content

Commit 22c93c9

Browse files
committed
fix : narrow down the PLC0415 ignore list
1 parent 06e76fc commit 22c93c9

13 files changed

+24
-93
lines changed

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
@@ -77,8 +75,6 @@ def regenerate_chunks_for_context(context: Context):
7775
context (Context): The specific context instance to be updated.
7876
7977
"""
80-
from apps.ai.models.chunk import Chunk
81-
8278
context.chunks.all().delete()
8379
new_chunk_texts = Chunk.split_text(context.content)
8480

backend/pyproject.toml

Lines changed: 7 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -68,21 +68,19 @@ line-length = 99
6868
lint.select = [ "ALL" ]
6969
lint.extend-select = [ "I" ]
7070
lint.ignore = [
71-
"ANN", # https://docs.astral.sh/ruff/rules/#flake8-annotations-ann/
72-
"ARG002", # https://docs.astral.sh/ruff/rules/unused-method-argument/
73-
"C901", # https://docs.astral.sh/ruff/rules/complex-structure/
74-
"COM812", # https://docs.astral.sh/ruff/rules/missing-trailing-comma/
75-
"D407", # https://docs.astral.sh/ruff/rules/missing-dashed-underline-after-section/
76-
"DJ012", # https://docs.astral.sh/ruff/rules/django-unordered-body-content-in-model/
77-
"FIX002", # https://docs.astral.sh/ruff/rules/line-contains-todo/
78-
71+
"ANN", # https://docs.astral.sh/ruff/rules/#flake8-annotations-ann/
72+
"ARG002", # https://docs.astral.sh/ruff/rules/unused-method-argument/
73+
"C901", # https://docs.astral.sh/ruff/rules/complex-structure/
74+
"COM812", # https://docs.astral.sh/ruff/rules/missing-trailing-comma/
75+
"D407", # https://docs.astral.sh/ruff/rules/missing-dashed-underline-after-section/
76+
"DJ012", # https://docs.astral.sh/ruff/rules/django-unordered-body-content-in-model/
77+
"FIX002", # https://docs.astral.sh/ruff/rules/line-contains-todo/
7978
"PLR0912", # https://docs.astral.sh/ruff/rules/too-many-branches/
8079
"PLR0913", # https://docs.astral.sh/ruff/rules/too-many-arguments/
8180
"PLR0915", # https://docs.astral.sh/ruff/rules/too-many-statements/
8281
"RUF012", # https://docs.astral.sh/ruff/rules/mutable-class-default/
8382
"TD003", # https://docs.astral.sh/ruff/rules/missing-todo-link/
8483
]
85-
8684
lint.per-file-ignores."**/__init__.py" = [
8785
"D104", # https://docs.astral.sh/ruff/rules/undocumented-public-package/
8886
"F401", # https://docs.astral.sh/ruff/rules/unused-import/
@@ -122,9 +120,6 @@ lint.per-file-ignores."**/tests/**/*.py" = [
122120
]
123121

124122
# specific files that need PLC0415 ignored
125-
lint.per-file-ignores."apps/ai/common/utils.py" = [
126-
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
127-
]
128123
lint.per-file-ignores."apps/github/models/mixins/organization.py" = [
129124
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
130125
]
@@ -164,45 +159,12 @@ lint.per-file-ignores."apps/slack/events/member_joined_channel/contribute.py" =
164159
lint.per-file-ignores."apps/slack/utils.py" = [
165160
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
166161
]
167-
lint.per-file-ignores."tests/apps/ai/management/commands/ai_update_chapter_chunks_test.py" = [
168-
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
169-
]
170-
lint.per-file-ignores."tests/apps/ai/management/commands/ai_update_chapter_context_test.py" = [
171-
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
172-
]
173-
lint.per-file-ignores."tests/apps/ai/management/commands/ai_update_committee_chunks_test.py" = [
174-
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
175-
]
176-
lint.per-file-ignores."tests/apps/ai/management/commands/ai_update_committee_context_test.py" = [
177-
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
178-
]
179-
lint.per-file-ignores."tests/apps/ai/management/commands/ai_update_event_chunks_test.py" = [
180-
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
181-
]
182-
lint.per-file-ignores."tests/apps/ai/management/commands/ai_update_event_context_test.py" = [
183-
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
184-
]
185-
lint.per-file-ignores."tests/apps/ai/management/commands/ai_update_project_chunks_test.py" = [
186-
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
187-
]
188-
lint.per-file-ignores."tests/apps/ai/management/commands/ai_update_project_context_test.py" = [
189-
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
190-
]
191-
lint.per-file-ignores."tests/apps/ai/management/commands/ai_update_slack_message_chunks_test.py" = [
192-
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
193-
]
194-
lint.per-file-ignores."tests/apps/ai/management/commands/ai_update_slack_message_context_test.py" = [
195-
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
196-
]
197162
lint.per-file-ignores."tests/apps/ai/models/chunk_test.py" = [
198163
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
199164
]
200165
lint.per-file-ignores."tests/apps/ai/models/context_test.py" = [
201166
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
202167
]
203-
lint.per-file-ignores."tests/apps/github/management/commands/github_get_installation_id_test.py" = [
204-
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
205-
]
206168
lint.per-file-ignores."tests/apps/slack/views_test.py" = [
207169
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
208170
]

backend/tests/apps/ai/management/commands/ai_update_chapter_chunks_test.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from django.core.management.base import BaseCommand
55

66
from apps.ai.management.commands.ai_update_chapter_chunks import Command
7+
from apps.owasp.models.chapter import Chapter
78

89

910
@pytest.fixture
@@ -24,8 +25,6 @@ def test_command_inheritance(self, command):
2425
assert isinstance(command, BaseCommand)
2526

2627
def test_model_class_property(self, command):
27-
from apps.owasp.models.chapter import Chapter
28-
2928
assert command.model_class == Chapter
3029

3130
def test_entity_name_property(self, command):

backend/tests/apps/ai/management/commands/ai_update_chapter_context_test.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
import pytest
66

7+
from apps.ai.common.base.context_command import BaseContextCommand
78
from apps.ai.management.commands.ai_update_chapter_context import Command
9+
from apps.owasp.models.chapter import Chapter
810

911

1012
@pytest.fixture
@@ -23,8 +25,6 @@ def mock_chapter():
2325
class TestAiCreateChapterContextCommand:
2426
def test_command_inheritance(self, command):
2527
"""Test that the command inherits from BaseContextCommand."""
26-
from apps.ai.common.base.context_command import BaseContextCommand
27-
2828
assert isinstance(command, BaseContextCommand)
2929

3030
def test_command_help_text(self, command):
@@ -33,8 +33,6 @@ def test_command_help_text(self, command):
3333

3434
def test_model_class_property(self, command):
3535
"""Test the model_class property returns Chapter."""
36-
from apps.owasp.models.chapter import Chapter
37-
3836
assert command.model_class == Chapter
3937

4038
def test_entity_name_property(self, command):

backend/tests/apps/ai/management/commands/ai_update_committee_chunks_test.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from django.core.management.base import BaseCommand
77

88
from apps.ai.management.commands.ai_update_committee_chunks import Command
9+
from apps.owasp.models.committee import Committee
910

1011

1112
@pytest.fixture
@@ -35,8 +36,6 @@ def test_command_inheritance(self, command):
3536

3637
def test_model_class_method(self, command):
3738
"""Test the model_class method returns Committee."""
38-
from apps.owasp.models.committee import Committee
39-
4039
assert command.model_class == Committee
4140

4241
def test_entity_name_method(self, command):

backend/tests/apps/ai/management/commands/ai_update_committee_context_test.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
import pytest
66

7+
from apps.ai.common.base.context_command import BaseContextCommand
78
from apps.ai.management.commands.ai_update_committee_context import Command
9+
from apps.owasp.models.committee import Committee
810

911

1012
@pytest.fixture
@@ -30,8 +32,6 @@ class TestAiCreateCommitteeContextCommand:
3032

3133
def test_command_inheritance(self, command):
3234
"""Test that the command inherits from BaseContextCommand."""
33-
from apps.ai.common.base.context_command import BaseContextCommand
34-
3535
assert isinstance(command, BaseContextCommand)
3636

3737
def test_command_help_text(self, command):
@@ -40,8 +40,6 @@ def test_command_help_text(self, command):
4040

4141
def test_model_class_method(self, command):
4242
"""Test the model_class method returns Committee."""
43-
from apps.owasp.models.committee import Committee
44-
4543
assert command.model_class == Committee
4644

4745
def test_entity_name_method(self, command):

backend/tests/apps/ai/management/commands/ai_update_event_chunks_test.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from django.core.management.base import BaseCommand
77

88
from apps.ai.management.commands.ai_update_event_chunks import Command
9+
from apps.owasp.models.event import Event
910

1011

1112
@pytest.fixture
@@ -32,8 +33,6 @@ def test_command_inheritance(self, command):
3233

3334
def test_model_class_property(self, command):
3435
"""Test the model_class property returns Event."""
35-
from apps.owasp.models.event import Event
36-
3736
assert command.model_class == Event
3837

3938
def test_entity_name_property(self, command):

backend/tests/apps/ai/management/commands/ai_update_event_context_test.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
import pytest
66

7+
from apps.ai.common.base.context_command import BaseContextCommand
78
from apps.ai.management.commands.ai_update_event_context import Command
9+
from apps.owasp.models.event import Event
810

911

1012
@pytest.fixture
@@ -23,8 +25,6 @@ def mock_event():
2325
class TestAiCreateEventContextCommand:
2426
def test_command_inheritance(self, command):
2527
"""Test that the command inherits from BaseContextCommand."""
26-
from apps.ai.common.base.context_command import BaseContextCommand
27-
2828
assert isinstance(command, BaseContextCommand)
2929

3030
def test_command_help_text(self, command):
@@ -33,8 +33,6 @@ def test_command_help_text(self, command):
3333

3434
def test_model_class_property(self, command):
3535
"""Test the model_class property returns Event."""
36-
from apps.owasp.models.event import Event
37-
3836
assert command.model_class == Event
3937

4038
def test_entity_name_property(self, command):

backend/tests/apps/ai/management/commands/ai_update_project_chunks_test.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from django.core.management.base import BaseCommand
55

66
from apps.ai.management.commands.ai_update_project_chunks import Command
7+
from apps.owasp.models.project import Project
78

89

910
@pytest.fixture
@@ -24,8 +25,6 @@ def test_command_inheritance(self, command):
2425
assert isinstance(command, BaseCommand)
2526

2627
def test_model_class_property(self, command):
27-
from apps.owasp.models.project import Project
28-
2928
assert command.model_class == Project
3029

3130
def test_entity_name_property(self, command):

backend/tests/apps/ai/management/commands/ai_update_project_context_test.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
import pytest
44

5+
from apps.ai.common.base.context_command import BaseContextCommand
56
from apps.ai.management.commands.ai_update_project_context import Command
7+
from apps.owasp.models.project import Project
68

79

810
@pytest.fixture
@@ -21,8 +23,6 @@ def mock_project():
2123
class TestAiCreateProjectContextCommand:
2224
def test_command_inheritance(self, command):
2325
"""Test that the command inherits from BaseContextCommand."""
24-
from apps.ai.common.base.context_command import BaseContextCommand
25-
2626
assert isinstance(command, BaseContextCommand)
2727

2828
def test_command_help_text(self, command):
@@ -31,8 +31,6 @@ def test_command_help_text(self, command):
3131

3232
def test_model_class_property(self, command):
3333
"""Test the model_class property returns Project."""
34-
from apps.owasp.models.project import Project
35-
3634
assert command.model_class == Project
3735

3836
def test_entity_name_property(self, command):

0 commit comments

Comments
 (0)