Skip to content

Commit 7e61680

Browse files
committed
Use ruff linting and formatting recommendations
1 parent 3c1b07e commit 7e61680

File tree

76 files changed

+460
-423
lines changed

Some content is hidden

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

76 files changed

+460
-423
lines changed

src/khoj/app/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
1. Import the include() function: from django.urls import include, path
1515
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
1616
"""
17+
1718
from django.contrib import admin
1819
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
1920
from django.urls import path

src/khoj/configure.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,8 @@ def configure_server(
228228
user: KhojUser = None,
229229
):
230230
# Update Config
231-
if config == None:
232-
logger.info(f"Initializing with default config.")
231+
if config is None:
232+
logger.info("Initializing with default config.")
233233
config = FullConfig()
234234
state.config = config
235235

src/khoj/database/adapters/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1918,9 +1918,9 @@ def apply_filters(user: KhojUser, query: str, file_type_filter: str = None, agen
19181918

19191919
owner_filter = Q()
19201920

1921-
if user != None:
1921+
if user is not None:
19221922
owner_filter = Q(user=user)
1923-
if agent != None:
1923+
if agent is not None:
19241924
owner_filter |= Q(agent=agent)
19251925

19261926
if owner_filter == Q():
@@ -1980,9 +1980,9 @@ def search_with_embeddings(
19801980
):
19811981
owner_filter = Q()
19821982

1983-
if user != None:
1983+
if user is not None:
19841984
owner_filter = Q(user=user)
1985-
if agent != None:
1985+
if agent is not None:
19861986
owner_filter |= Q(agent=agent)
19871987

19881988
if owner_filter == Q():

src/khoj/database/management/commands/delete_orphaned_fileobjects.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from django.core.management.base import BaseCommand
2-
from django.db import transaction
32
from django.db.models import Exists, OuterRef
43

54
from khoj.database.models import Entry, FileObject

src/khoj/database/migrations/0064_remove_conversation_temp_id_alter_conversation_id.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def update_conversation_id_in_job_state(apps, schema_editor):
4141
job.save()
4242
except Conversation.DoesNotExist:
4343
pass
44-
except LookupError as e:
44+
except LookupError:
4545
pass
4646

4747

src/khoj/database/migrations/0075_migrate_generated_assets_and_validate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Made manually by sabaimran for use by Django 5.0.9 on 2024-12-01 16:59
22

3-
from django.db import migrations, models
3+
from django.db import migrations
44

55
# This script was written alongside when Pydantic validation was added to the Conversation conversation_log field.
66

src/khoj/database/models/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -580,12 +580,12 @@ def clean(self):
580580
error = {}
581581
if self.model_type == self.ModelType.OPENAI:
582582
if self.api_key and self.ai_model_api:
583-
error[
584-
"api_key"
585-
] = "Both API key and AI Model API cannot be set for OpenAI models. Please set only one of them."
586-
error[
587-
"ai_model_api"
588-
] = "Both API key and OpenAI config cannot be set for OpenAI models. Please set only one of them."
583+
error["api_key"] = (
584+
"Both API key and AI Model API cannot be set for OpenAI models. Please set only one of them."
585+
)
586+
error["ai_model_api"] = (
587+
"Both API key and OpenAI config cannot be set for OpenAI models. Please set only one of them."
588+
)
589589
if self.model_type != self.ModelType.OPENAI and self.model_type != self.ModelType.GOOGLE:
590590
if not self.api_key:
591591
error["api_key"] = "The API key field must be set for non OpenAI, non Google models."

src/khoj/database/tests.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
from django.test import TestCase
2-
31
# Create your tests here.

src/khoj/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
""" Main module for Khoj
2-
isort:skip_file
1+
"""Main module for Khoj
2+
isort:skip_file
33
"""
44

55
from contextlib import redirect_stdout
@@ -189,7 +189,7 @@ def run(should_start_server=True):
189189
static_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "static")
190190
if not os.path.exists(static_dir):
191191
os.mkdir(static_dir)
192-
app.mount(f"/static", StaticFiles(directory=static_dir), name=static_dir)
192+
app.mount("/static", StaticFiles(directory=static_dir), name=static_dir)
193193

194194
# Configure Middleware
195195
configure_middleware(app, state.ssl_config)

src/khoj/manage.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env python
22
"""Django's command-line utility for administrative tasks."""
3+
34
import os
45
import sys
56

0 commit comments

Comments
 (0)