Skip to content

Commit 670929e

Browse files
authored
dateparser: use PEP 604 (#5977)
Co-authored-by: hauntsaninja <>
1 parent f6e4c9c commit 670929e

File tree

4 files changed

+13
-15
lines changed

4 files changed

+13
-15
lines changed

stubs/dateparser/dateparser/languages/loader.pyi

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from collections import OrderedDict
2-
from typing import Any, Iterator, List, Optional, Union
2+
from typing import Any, Iterator, List
33

44
from .locale import Locale
55

@@ -8,16 +8,16 @@ LOCALE_SPLIT_PATTERN: Any
88
class LocaleDataLoader:
99
def get_locale_map(
1010
self,
11-
languages: Optional[List[str]] = ...,
12-
locales: Optional[List[str]] = ...,
11+
languages: List[str] | None = ...,
12+
locales: List[str] | None = ...,
1313
region: str | None = ...,
1414
use_given_order: bool = ...,
1515
allow_conflicting_locales: bool = ...,
16-
) -> OrderedDict[str, Union[List[Any], str, int]]: ...
16+
) -> OrderedDict[str, List[Any] | str | int]: ...
1717
def get_locales(
1818
self,
19-
languages: Optional[List[str]] = ...,
20-
locales: Optional[List[str]] = ...,
19+
languages: List[str] | None = ...,
20+
locales: List[str] | None = ...,
2121
region: str | None = ...,
2222
use_given_order: bool = ...,
2323
allow_conflicting_locales: bool = ...,
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import sys
22
from datetime import datetime
3-
from typing import Any, List, Mapping, Optional, Set, Tuple, Union, overload
3+
from typing import Any, List, Mapping, Set, Tuple, overload
44

55
if sys.version_info >= (3, 8):
66
from typing import Literal
@@ -10,14 +10,14 @@ else:
1010
@overload
1111
def search_dates(
1212
text: str,
13-
languages: Optional[Union[List[str], Tuple[str], Set[str]]],
14-
settings: Optional[Mapping[Any, Any]],
13+
languages: List[str] | Tuple[str] | Set[str] | None,
14+
settings: Mapping[Any, Any] | None,
1515
add_detected_language: Literal[True],
1616
) -> List[Tuple[str, datetime, str]]: ...
1717
@overload
1818
def search_dates(
1919
text: str,
20-
languages: Optional[Union[List[str], Tuple[str], Set[str]]] = ...,
21-
settings: Optional[Mapping[Any, Any]] = ...,
20+
languages: List[str] | Tuple[str] | Set[str] | None = ...,
21+
settings: Mapping[Any, Any] | None = ...,
2222
add_detected_language: Literal[False] = ...,
2323
) -> List[Tuple[str, datetime]]: ...

stubs/dateparser/dateparser/utils/__init__.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
from collections import OrderedDict
2-
from typing import Any, List, Mapping, Union
2+
from typing import Any, List, Mapping
33

44
def strip_braces(date_string: str) -> str: ...
55
def normalize_unicode(string: str, form: str = ...) -> str: ...
66
def combine_dicts(
77
primary_dict: Mapping[Any, Any], supplementary_dict: Mapping[Any, Any]
8-
) -> OrderedDict[str, Union[str, List[Any]]]: ...
8+
) -> OrderedDict[str, str | List[Any]]: ...
99
def find_date_separator(format) -> Any: ...
1010
def localize_timezone(date_time, tz_string): ...
1111
def apply_tzdatabase_timezone(date_time, pytz_string): ...

tests/check_pep_604.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ def main() -> None:
5959
continue
6060
if "stubs/protobuf/google/protobuf" in str(path): # TODO: fix protobuf stubs
6161
continue
62-
if "stubs/dateparser/" in str(path): # TODO: fix dateparser
63-
continue
6462

6563
with open(path) as f:
6664
tree = ast.parse(f.read())

0 commit comments

Comments
 (0)