|
4 | 4 | from pathlib import Path |
5 | 5 | from typing import Optional, Set |
6 | 6 |
|
| 7 | +from pydantic import BaseModel, Field |
| 8 | + |
7 | 9 | from gitingest.config import MAX_FILE_SIZE |
8 | 10 |
|
9 | 11 |
|
@@ -37,26 +39,30 @@ class CloneConfig: |
37 | 39 | blob: bool = False |
38 | 40 |
|
39 | 41 |
|
40 | | -@dataclass |
41 | | -class IngestionQuery: # pylint: disable=too-many-instance-attributes |
| 42 | +class IngestionQuery(BaseModel): # pylint: disable=too-many-instance-attributes |
42 | 43 | """ |
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. |
44 | 45 | """ |
45 | 46 |
|
46 | | - user_name: Optional[str] |
47 | | - repo_name: Optional[str] |
| 47 | + user_name: Optional[str] = None |
| 48 | + repo_name: Optional[str] = None |
48 | 49 | local_path: Path |
49 | | - url: Optional[str] |
| 50 | + url: Optional[str] = None |
50 | 51 | slug: str |
51 | 52 | id: str |
52 | 53 | subpath: str = "/" |
53 | 54 | type: Optional[str] = None |
54 | 55 | branch: Optional[str] = None |
55 | 56 | commit: Optional[str] = None |
56 | | - max_file_size: int = MAX_FILE_SIZE |
| 57 | + max_file_size: int = Field(default=MAX_FILE_SIZE) |
57 | 58 | ignore_patterns: Optional[Set[str]] = None |
58 | 59 | 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 |
60 | 66 |
|
61 | 67 | def extact_clone_config(self) -> CloneConfig: |
62 | 68 | """ |
|
0 commit comments