Skip to content

Commit e42e7d2

Browse files
Copilotjgbradley1
andcommitted
Fix linting issues found by ruff check --fix
Co-authored-by: jgbradley1 <654554+jgbradley1@users.noreply.github.com>
1 parent de7afaf commit e42e7d2

File tree

3 files changed

+19
-15
lines changed

3 files changed

+19
-15
lines changed

graphrag/config/defaults.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from dataclasses import dataclass, field
77
from pathlib import Path
8-
from typing import Literal
8+
from typing import ClassVar, Literal
99

1010
from graphrag.config.embeddings import default_embeddings
1111
from graphrag.config.enums import (
@@ -55,7 +55,7 @@ class BasicSearchDefaults:
5555
class CacheDefaults:
5656
"""Default values for cache."""
5757

58-
type = CacheType.file
58+
type: ClassVar[CacheType] = CacheType.file
5959
base_dir: str = "cache"
6060
connection_string: None = None
6161
container_name: None = None
@@ -70,7 +70,7 @@ class ChunksDefaults:
7070
size: int = 1200
7171
overlap: int = 100
7272
group_by_columns: list[str] = field(default_factory=lambda: ["id"])
73-
strategy = ChunkStrategyType.tokens
73+
strategy: ClassVar[ChunkStrategyType] = ChunkStrategyType.tokens
7474
encoding_model: str = "cl100k_base"
7575
prepend_metadata: bool = False
7676
chunk_size_includes_metadata: bool = False
@@ -120,8 +120,8 @@ class DriftSearchDefaults:
120120
local_search_temperature: float = 0
121121
local_search_top_p: float = 1
122122
local_search_n: int = 1
123-
local_search_llm_max_gen_tokens = None
124-
local_search_llm_max_gen_completion_tokens = None
123+
local_search_llm_max_gen_tokens: ClassVar[None] = None
124+
local_search_llm_max_gen_completion_tokens: ClassVar[None] = None
125125
chat_model_id: str = DEFAULT_CHAT_MODEL_ID
126126
embedding_model_id: str = DEFAULT_EMBEDDING_MODEL_ID
127127

@@ -184,7 +184,9 @@ class ExtractGraphDefaults:
184184
class TextAnalyzerDefaults:
185185
"""Default values for text analyzer."""
186186

187-
extractor_type = NounPhraseExtractorType.RegexEnglish
187+
extractor_type: ClassVar[NounPhraseExtractorType] = (
188+
NounPhraseExtractorType.RegexEnglish
189+
)
188190
model_name: str = "en_core_web_md"
189191
max_word_length: int = 15
190192
word_delimiter: str = " "
@@ -238,8 +240,8 @@ class GlobalSearchDefaults:
238240
class InputDefaults:
239241
"""Default values for input."""
240242

241-
type = InputType.file
242-
file_type = InputFileType.text
243+
type: ClassVar[InputType] = InputType.file
244+
file_type: ClassVar[InputFileType] = InputFileType.text
243245
base_dir: str = "input"
244246
connection_string: None = None
245247
storage_account_blob_url: None = None
@@ -257,7 +259,7 @@ class LanguageModelDefaults:
257259
"""Default values for language model."""
258260

259261
api_key: None = None
260-
auth_type = AuthType.APIKey
262+
auth_type: ClassVar[AuthType] = AuthType.APIKey
261263
encoding_model: str = ""
262264
max_tokens: int | None = None
263265
temperature: float = 0
@@ -304,7 +306,7 @@ class LocalSearchDefaults:
304306
class OutputDefaults:
305307
"""Default values for output."""
306308

307-
type = OutputType.file
309+
type: ClassVar[OutputType] = OutputType.file
308310
base_dir: str = DEFAULT_OUTPUT_BASE_DIR
309311
connection_string: None = None
310312
container_name: None = None
@@ -329,7 +331,7 @@ class PruneGraphDefaults:
329331
class ReportingDefaults:
330332
"""Default values for reporting."""
331333

332-
type = ReportingType.file
334+
type: ClassVar[ReportingType] = ReportingType.file
333335
base_dir: str = "logs"
334336
connection_string: None = None
335337
container_name: None = None
@@ -367,7 +369,7 @@ class UmapDefaults:
367369
class UpdateIndexOutputDefaults:
368370
"""Default values for update index output."""
369371

370-
type = OutputType.file
372+
type: ClassVar[OutputType] = OutputType.file
371373
base_dir: str = "update_output"
372374
connection_string: None = None
373375
container_name: None = None
@@ -378,7 +380,7 @@ class UpdateIndexOutputDefaults:
378380
class VectorStoreDefaults:
379381
"""Default values for vector stores."""
380382

381-
type = VectorStoreType.LanceDB.value
383+
type: ClassVar[str] = VectorStoreType.LanceDB.value
382384
db_uri: str = str(Path(DEFAULT_OUTPUT_BASE_DIR) / "lancedb")
383385
container_name: str = "default"
384386
overwrite: bool = True

graphrag/language_model/manager.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
from typing import TYPE_CHECKING, Any, ClassVar
1313

14+
from typing_extensions import Self
15+
1416
from graphrag.language_model.factory import ModelFactory
1517

1618
if TYPE_CHECKING:
@@ -22,7 +24,7 @@ class ModelManager:
2224

2325
_instance: ClassVar[ModelManager | None] = None
2426

25-
def __new__(cls) -> ModelManager: # noqa: PYI034: False positive
27+
def __new__(cls) -> Self:
2628
"""Create a new instance of LLMManager if it does not exist."""
2729
if cls._instance is None:
2830
cls._instance = super().__new__(cls)

graphrag/storage/cosmosdb_pipeline_storage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ async def set(self, key: str, value: Any, encoding: str | None = None) -> None:
251251
orient="records", lines=False, force_ascii=False
252252
)
253253
if value_json is None:
254-
log.exception("Error converting output %s to json", key)
254+
log.error("Error converting output %s to json", key)
255255
else:
256256
cosmosdb_item_list = json.loads(value_json)
257257
for index, cosmosdb_item in enumerate(cosmosdb_item_list):

0 commit comments

Comments
 (0)