Skip to content

Commit 939183c

Browse files
committed
refactor: Convert IngestionQuery to Pydantic model
1 parent 6981246 commit 939183c

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/gitingest/ingestion_schema.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
from pathlib import Path
55
from typing import Optional, Set
66

7+
from pydantic import BaseModel, Field
8+
79
from gitingest.config import MAX_FILE_SIZE
810

911

@@ -37,26 +39,30 @@ class CloneConfig:
3739
blob: bool = False
3840

3941

40-
@dataclass
41-
class IngestionQuery: # pylint: disable=too-many-instance-attributes
42+
class IngestionQuery(BaseModel): # pylint: disable=too-many-instance-attributes
4243
"""
43-
Dataclass to store the parsed details of the repository or file path.
44+
Pydantic model to store the parsed details of the repository or file path.
4445
"""
4546

46-
user_name: Optional[str]
47-
repo_name: Optional[str]
47+
user_name: Optional[str] = None
48+
repo_name: Optional[str] = None
4849
local_path: Path
49-
url: Optional[str]
50+
url: Optional[str] = None
5051
slug: str
5152
id: str
5253
subpath: str = "/"
5354
type: Optional[str] = None
5455
branch: Optional[str] = None
5556
commit: Optional[str] = None
56-
max_file_size: int = MAX_FILE_SIZE
57+
max_file_size: int = Field(default=MAX_FILE_SIZE)
5758
ignore_patterns: Optional[Set[str]] = None
5859
include_patterns: Optional[Set[str]] = None
59-
pattern_type: Optional[str] = None
60+
pattern_type: Optional[str] = None # TODO remove this field
61+
62+
class Config:
63+
"""Pydantic model configuration."""
64+
65+
arbitrary_types_allowed = True
6066

6167
def extact_clone_config(self) -> CloneConfig:
6268
"""

0 commit comments

Comments
 (0)