Skip to content

Commit 955b9ff

Browse files
committed
Pyright
1 parent 1f160c1 commit 955b9ff

File tree

8 files changed

+52
-63
lines changed

8 files changed

+52
-63
lines changed

graphrag/config/models/graph_rag_config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ def __str__(self):
4040
"""Get a string representation."""
4141
return self.model_dump_json(indent=4)
4242

43-
root_dir: str | None = Field(
44-
description="The root directory for the configuration.", default=None
43+
root_dir: str = Field(
44+
description="The root directory for the configuration.", default="."
4545
)
4646

4747
reporting: ReportingConfig = Field(

graphrag/index/config/cache.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77

88
from typing import Generic, Literal, TypeVar
99

10-
from pydantic import BaseModel
11-
from pydantic import Field as pydantic_Field
10+
from pydantic import BaseModel, Field
1211

1312
from graphrag.config.enums import CacheType
1413

@@ -27,7 +26,7 @@ class PipelineFileCacheConfig(PipelineCacheConfig[Literal[CacheType.file]]):
2726
type: Literal[CacheType.file] = CacheType.file
2827
"""The type of cache."""
2928

30-
base_dir: str | None = pydantic_Field(
29+
base_dir: str | None = Field(
3130
description="The base directory for the cache.", default=None
3231
)
3332
"""The base directory for the cache."""
@@ -53,22 +52,20 @@ class PipelineBlobCacheConfig(PipelineCacheConfig[Literal[CacheType.blob]]):
5352
type: Literal[CacheType.blob] = CacheType.blob
5453
"""The type of cache."""
5554

56-
base_dir: str | None = pydantic_Field(
55+
base_dir: str | None = Field(
5756
description="The base directory for the cache.", default=None
5857
)
5958
"""The base directory for the cache."""
6059

61-
connection_string: str | None = pydantic_Field(
60+
connection_string: str | None = Field(
6261
description="The blob cache connection string for the cache.", default=None
6362
)
6463
"""The blob cache connection string for the cache."""
6564

66-
container_name: str | None = pydantic_Field(
67-
description="The container name for cache", default=None
68-
)
65+
container_name: str = Field(description="The container name for cache", default="")
6966
"""The container name for cache"""
7067

71-
storage_account_blob_url: str | None = pydantic_Field(
68+
storage_account_blob_url: str | None = Field(
7269
description="The storage account blob url for cache", default=None
7370
)
7471
"""The storage account blob url for cache"""

graphrag/index/config/input.py

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77

88
from typing import Generic, Literal, TypeVar
99

10-
from pydantic import BaseModel
11-
from pydantic import Field as pydantic_Field
10+
from pydantic import BaseModel, Field
1211

1312
from graphrag.config.enums import InputFileType, InputType
1413
from graphrag.index.config.workflow import PipelineWorkflowStep
@@ -22,49 +21,47 @@ class PipelineInputConfig(BaseModel, Generic[T]):
2221
file_type: T
2322
"""The file type of input."""
2423

25-
type: InputType | None = pydantic_Field(
24+
type: InputType | None = Field(
2625
description="The input type to use.",
2726
default=None,
2827
)
2928
"""The input type to use."""
3029

31-
connection_string: str | None = pydantic_Field(
30+
connection_string: str | None = Field(
3231
description="The blob cache connection string for the input files.",
3332
default=None,
3433
)
3534
"""The blob cache connection string for the input files."""
3635

37-
storage_account_blob_url: str | None = pydantic_Field(
36+
storage_account_blob_url: str | None = Field(
3837
description="The storage account blob url for the input files.", default=None
3938
)
4039
"""The storage account blob url for the input files."""
4140

42-
container_name: str | None = pydantic_Field(
41+
container_name: str | None = Field(
4342
description="The container name for input files.", default=None
4443
)
4544
"""The container name for the input files."""
4645

47-
base_dir: str | None = pydantic_Field(
46+
base_dir: str | None = Field(
4847
description="The base directory for the input files.", default=None
4948
)
5049
"""The base directory for the input files."""
5150

52-
file_pattern: str = pydantic_Field(
53-
description="The regex file pattern for the input files."
54-
)
51+
file_pattern: str = Field(description="The regex file pattern for the input files.")
5552
"""The regex file pattern for the input files."""
5653

57-
file_filter: dict[str, str] | None = pydantic_Field(
54+
file_filter: dict[str, str] | None = Field(
5855
description="The optional file filter for the input files.", default=None
5956
)
6057
"""The optional file filter for the input files."""
6158

62-
post_process: list[PipelineWorkflowStep] | None = pydantic_Field(
59+
post_process: list[PipelineWorkflowStep] | None = Field(
6360
description="The post processing steps for the input.", default=None
6461
)
6562
"""The post processing steps for the input."""
6663

67-
encoding: str | None = pydantic_Field(
64+
encoding: str | None = Field(
6865
description="The encoding for the input files.", default=None
6966
)
7067
"""The encoding for the input files."""
@@ -75,28 +72,28 @@ class PipelineCSVInputConfig(PipelineInputConfig[Literal[InputFileType.csv]]):
7572

7673
file_type: Literal[InputFileType.csv] = InputFileType.csv
7774

78-
source_column: str | None = pydantic_Field(
75+
source_column: str | None = Field(
7976
description="The column to use as the source of the document.", default=None
8077
)
8178
"""The column to use as the source of the document."""
8279

83-
timestamp_column: str | None = pydantic_Field(
80+
timestamp_column: str | None = Field(
8481
description="The column to use as the timestamp of the document.", default=None
8582
)
8683
"""The column to use as the timestamp of the document."""
8784

88-
timestamp_format: str | None = pydantic_Field(
85+
timestamp_format: str | None = Field(
8986
description="The format of the timestamp column, so it can be parsed correctly.",
9087
default=None,
9188
)
9289
"""The format of the timestamp column, so it can be parsed correctly."""
9390

94-
text_column: str | None = pydantic_Field(
91+
text_column: str | None = Field(
9592
description="The column to use as the text of the document.", default=None
9693
)
9794
"""The column to use as the text of the document."""
9895

99-
title_column: str | None = pydantic_Field(
96+
title_column: str | None = Field(
10097
description="The column to use as the title of the document.", default=None
10198
)
10299
"""The column to use as the title of the document."""
@@ -108,7 +105,7 @@ class PipelineTextInputConfig(PipelineInputConfig[Literal[InputFileType.text]]):
108105
file_type: Literal[InputFileType.text] = InputFileType.text
109106

110107
# Text Specific
111-
title_text_length: int | None = pydantic_Field(
108+
title_text_length: int | None = Field(
112109
description="Number of characters to use from the text as the title.",
113110
default=None,
114111
)

graphrag/index/config/pipeline.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
from __future__ import annotations
77

88
from devtools import pformat
9-
from pydantic import BaseModel
10-
from pydantic import Field as pydantic_Field
9+
from pydantic import BaseModel, Field
1110

1211
from graphrag.index.config.cache import PipelineCacheConfigTypes
1312
from graphrag.index.config.input import PipelineInputConfigTypes
@@ -27,43 +26,41 @@ def __str__(self):
2726
"""Get a string representation."""
2827
return str(self.model_dump_json(indent=4))
2928

30-
extends: list[str] | str | None = pydantic_Field(
29+
extends: list[str] | str | None = Field(
3130
description="Extends another pipeline configuration", default=None
3231
)
3332
"""Extends another pipeline configuration"""
3433

35-
input: PipelineInputConfigTypes | None = pydantic_Field(
34+
input: PipelineInputConfigTypes | None = Field(
3635
default=None, discriminator="file_type"
3736
)
3837
"""The input configuration for the pipeline."""
3938

40-
reporting: PipelineReportingConfigTypes | None = pydantic_Field(
39+
reporting: PipelineReportingConfigTypes | None = Field(
4140
default=None, discriminator="type"
4241
)
4342
"""The reporting configuration for the pipeline."""
4443

45-
storage: PipelineStorageConfigTypes | None = pydantic_Field(
44+
storage: PipelineStorageConfigTypes | None = Field(
4645
default=None, discriminator="type"
4746
)
4847
"""The storage configuration for the pipeline."""
4948

50-
update_index_storage: PipelineStorageConfigTypes | None = pydantic_Field(
49+
update_index_storage: PipelineStorageConfigTypes | None = Field(
5150
default=None, discriminator="type"
5251
)
5352
"""The storage configuration for the updated index."""
5453

55-
cache: PipelineCacheConfigTypes | None = pydantic_Field(
56-
default=None, discriminator="type"
57-
)
54+
cache: PipelineCacheConfigTypes | None = Field(default=None, discriminator="type")
5855
"""The cache configuration for the pipeline."""
5956

60-
root_dir: str | None = pydantic_Field(
57+
root_dir: str | None = Field(
6158
description="The root directory for the pipeline. All other paths will be based on this root_dir.",
6259
default=None,
6360
)
6461
"""The root directory for the pipeline."""
6562

66-
workflows: list[PipelineWorkflowReference] = pydantic_Field(
63+
workflows: list[PipelineWorkflowReference] = Field(
6764
description="The workflows for the pipeline.", default_factory=list
6865
)
6966
"""The workflows for the pipeline."""

graphrag/index/config/reporting.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77

88
from typing import Generic, Literal, TypeVar
99

10-
from pydantic import BaseModel
11-
from pydantic import Field as pydantic_Field
10+
from pydantic import BaseModel, Field
1211

1312
from graphrag.config.enums import ReportingType
1413

@@ -27,7 +26,7 @@ class PipelineFileReportingConfig(PipelineReportingConfig[Literal[ReportingType.
2726
type: Literal[ReportingType.file] = ReportingType.file
2827
"""The type of reporting."""
2928

30-
base_dir: str | None = pydantic_Field(
29+
base_dir: str | None = Field(
3130
description="The base directory for the reporting.", default=None
3231
)
3332
"""The base directory for the reporting."""
@@ -48,23 +47,23 @@ class PipelineBlobReportingConfig(PipelineReportingConfig[Literal[ReportingType.
4847
type: Literal[ReportingType.blob] = ReportingType.blob
4948
"""The type of reporting."""
5049

51-
connection_string: str | None = pydantic_Field(
50+
connection_string: str | None = Field(
5251
description="The blob reporting connection string for the reporting.",
5352
default=None,
5453
)
5554
"""The blob reporting connection string for the reporting."""
5655

57-
container_name: str | None = pydantic_Field(
58-
description="The container name for reporting", default=None
56+
container_name: str = Field(
57+
description="The container name for reporting", default=""
5958
)
6059
"""The container name for reporting"""
6160

62-
storage_account_blob_url: str | None = pydantic_Field(
61+
storage_account_blob_url: str | None = Field(
6362
description="The storage account blob url for reporting", default=None
6463
)
6564
"""The storage account blob url for reporting"""
6665

67-
base_dir: str | None = pydantic_Field(
66+
base_dir: str | None = Field(
6867
description="The base directory for the reporting.", default=None
6968
)
7069
"""The base directory for the reporting."""

graphrag/index/config/storage.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77

88
from typing import Generic, Literal, TypeVar
99

10-
from pydantic import BaseModel
11-
from pydantic import Field as pydantic_Field
10+
from pydantic import BaseModel, Field
1211

1312
from graphrag.config.enums import StorageType
1413

@@ -27,7 +26,7 @@ class PipelineFileStorageConfig(PipelineStorageConfig[Literal[StorageType.file]]
2726
type: Literal[StorageType.file] = StorageType.file
2827
"""The type of storage."""
2928

30-
base_dir: str | None = pydantic_Field(
29+
base_dir: str | None = Field(
3130
description="The base directory for the storage.", default=None
3231
)
3332
"""The base directory for the storage."""
@@ -46,22 +45,22 @@ class PipelineBlobStorageConfig(PipelineStorageConfig[Literal[StorageType.blob]]
4645
type: Literal[StorageType.blob] = StorageType.blob
4746
"""The type of storage."""
4847

49-
connection_string: str | None = pydantic_Field(
48+
connection_string: str | None = Field(
5049
description="The blob storage connection string for the storage.", default=None
5150
)
5251
"""The blob storage connection string for the storage."""
5352

54-
container_name: str | None = pydantic_Field(
55-
description="The container name for storage", default=None
53+
container_name: str = Field(
54+
description="The container name for storage", default=""
5655
)
5756
"""The container name for storage."""
5857

59-
base_dir: str | None = pydantic_Field(
58+
base_dir: str | None = Field(
6059
description="The base directory for the storage.", default=None
6160
)
6261
"""The base directory for the storage."""
6362

64-
storage_account_blob_url: str | None = pydantic_Field(
63+
storage_account_blob_url: str | None = Field(
6564
description="The storage account blob url.", default=None
6665
)
6766
"""The storage account blob url."""

graphrag/index/config/workflow.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77

88
from typing import Any
99

10-
from pydantic import BaseModel
11-
from pydantic import Field as pydantic_Field
10+
from pydantic import BaseModel, Field
1211

1312
PipelineWorkflowStep = dict[str, Any]
1413
"""Represent a step in a workflow."""
@@ -20,15 +19,15 @@
2019
class PipelineWorkflowReference(BaseModel):
2120
"""Represent a reference to a workflow, and can optionally be the workflow itself."""
2221

23-
name: str | None = pydantic_Field(description="Name of the workflow.", default=None)
22+
name: str | None = Field(description="Name of the workflow.", default=None)
2423
"""Name of the workflow."""
2524

26-
steps: list[PipelineWorkflowStep] | None = pydantic_Field(
25+
steps: list[PipelineWorkflowStep] | None = Field(
2726
description="The optional steps for the workflow.", default=None
2827
)
2928
"""The optional steps for the workflow."""
3029

31-
config: PipelineWorkflowConfig | None = pydantic_Field(
30+
config: PipelineWorkflowConfig | None = Field(
3231
description="The optional configuration for the workflow.", default=None
3332
)
3433
"""The optional configuration for the workflow."""

graphrag/index/llm/mock_llm.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,5 @@ async def __call__(
4545
)
4646

4747
def child(self, name):
48+
"""Return a new mock LLM."""
4849
raise NotImplementedError

0 commit comments

Comments
 (0)