77import warnings
88from dataclasses import dataclass
99from pathlib import Path
10+ from typing import Optional , Union
1011from urllib .parse import unquote , urlparse
1112
1213from gitingest .config import MAX_FILE_SIZE , TMP_BASE_PATH
@@ -32,28 +33,28 @@ class ParsedQuery: # pylint: disable=too-many-instance-attributes
3233 Dataclass to store the parsed details of the repository or file path.
3334 """
3435
35- user_name : str | None
36- repo_name : str | None
36+ user_name : Optional [ str ]
37+ repo_name : Optional [ str ]
3738 subpath : str
3839 local_path : Path
39- url : str | None
40+ url : Optional [ str ]
4041 slug : str
4142 id : str
42- type : str | None = None
43- branch : str | None = None
44- commit : str | None = None
43+ type : Optional [ str ] = None
44+ branch : Optional [ str ] = None
45+ commit : Optional [ str ] = None
4546 max_file_size : int = MAX_FILE_SIZE
46- ignore_patterns : set [str ] | None = None
47- include_patterns : set [str ] | None = None
48- pattern_type : str | None = None
47+ ignore_patterns : Optional [ set [str ]] = None
48+ include_patterns : Optional [ set [str ]] = None
49+ pattern_type : Optional [ str ] = None
4950
5051
5152async def parse_query (
5253 source : str ,
5354 max_file_size : int ,
5455 from_web : bool ,
55- include_patterns : set [ str ] | str | None = None ,
56- ignore_patterns : set [ str ] | str | None = None ,
56+ include_patterns : Optional [ Union [ str , set [ str ]]] = None ,
57+ ignore_patterns : Optional [ Union [ str , set [ str ]]] = None ,
5758) -> ParsedQuery :
5859 """
5960 Parse the input source (URL or path) to extract relevant details for the query.
@@ -70,9 +71,9 @@ async def parse_query(
7071 The maximum file size in bytes to include.
7172 from_web : bool
7273 Flag indicating whether the source is a web URL.
73- include_patterns : set [str] | str | None , optional
74+ include_patterns : Union [str, set[ str]] , optional
7475 Patterns to include, by default None. Can be a set of strings or a single string.
75- ignore_patterns : set [str] | str | None , optional
76+ ignore_patterns : Union [str, set[ str]] , optional
7677 Patterns to ignore, by default None. Can be a set of strings or a single string.
7778
7879 Returns
@@ -208,7 +209,7 @@ async def _parse_repo_source(source: str) -> ParsedQuery:
208209 return parsed
209210
210211
211- async def _configure_branch_and_subpath (remaining_parts : list [str ], url : str ) -> str | None :
212+ async def _configure_branch_and_subpath (remaining_parts : list [str ], url : str ) -> Optional [ str ] :
212213 """
213214 Configure the branch and subpath based on the remaining parts of the URL.
214215 Parameters
@@ -219,7 +220,7 @@ async def _configure_branch_and_subpath(remaining_parts: list[str], url: str) ->
219220 The URL of the repository.
220221 Returns
221222 -------
222- str | None
223+ str, optional
223224 The branch name if found, otherwise None.
224225
225226 """
@@ -283,7 +284,7 @@ def _normalize_pattern(pattern: str) -> str:
283284 return pattern
284285
285286
286- def _parse_patterns (pattern : set [str ] | str ) -> set [str ]:
287+ def _parse_patterns (pattern : Union [str , set [ str ]] ) -> set [str ]:
287288 """
288289 Parse and validate file/directory patterns for inclusion or exclusion.
289290
0 commit comments