dateparser: use PEP 604 (#5977)

Co-authored-by: hauntsaninja <>
This commit is contained in:
Shantanu
2021-08-28 12:03:02 -07:00
committed by GitHub
parent f6e4c9c38f
commit 670929e908
4 changed files with 13 additions and 15 deletions

View File

@@ -1,5 +1,5 @@
from collections import OrderedDict
from typing import Any, Iterator, List, Optional, Union
from typing import Any, Iterator, List
from .locale import Locale
@@ -8,16 +8,16 @@ LOCALE_SPLIT_PATTERN: Any
class LocaleDataLoader:
def get_locale_map(
self,
languages: Optional[List[str]] = ...,
locales: Optional[List[str]] = ...,
languages: List[str] | None = ...,
locales: List[str] | None = ...,
region: str | None = ...,
use_given_order: bool = ...,
allow_conflicting_locales: bool = ...,
) -> OrderedDict[str, Union[List[Any], str, int]]: ...
) -> OrderedDict[str, List[Any] | str | int]: ...
def get_locales(
self,
languages: Optional[List[str]] = ...,
locales: Optional[List[str]] = ...,
languages: List[str] | None = ...,
locales: List[str] | None = ...,
region: str | None = ...,
use_given_order: bool = ...,
allow_conflicting_locales: bool = ...,

View File

@@ -1,6 +1,6 @@
import sys
from datetime import datetime
from typing import Any, List, Mapping, Optional, Set, Tuple, Union, overload
from typing import Any, List, Mapping, Set, Tuple, overload
if sys.version_info >= (3, 8):
from typing import Literal
@@ -10,14 +10,14 @@ else:
@overload
def search_dates(
text: str,
languages: Optional[Union[List[str], Tuple[str], Set[str]]],
settings: Optional[Mapping[Any, Any]],
languages: List[str] | Tuple[str] | Set[str] | None,
settings: Mapping[Any, Any] | None,
add_detected_language: Literal[True],
) -> List[Tuple[str, datetime, str]]: ...
@overload
def search_dates(
text: str,
languages: Optional[Union[List[str], Tuple[str], Set[str]]] = ...,
settings: Optional[Mapping[Any, Any]] = ...,
languages: List[str] | Tuple[str] | Set[str] | None = ...,
settings: Mapping[Any, Any] | None = ...,
add_detected_language: Literal[False] = ...,
) -> List[Tuple[str, datetime]]: ...

View File

@@ -1,11 +1,11 @@
from collections import OrderedDict
from typing import Any, List, Mapping, Union
from typing import Any, List, Mapping
def strip_braces(date_string: str) -> str: ...
def normalize_unicode(string: str, form: str = ...) -> str: ...
def combine_dicts(
primary_dict: Mapping[Any, Any], supplementary_dict: Mapping[Any, Any]
) -> OrderedDict[str, Union[str, List[Any]]]: ...
) -> OrderedDict[str, str | List[Any]]: ...
def find_date_separator(format) -> Any: ...
def localize_timezone(date_time, tz_string): ...
def apply_tzdatabase_timezone(date_time, pytz_string): ...

View File

@@ -59,8 +59,6 @@ def main() -> None:
continue
if "stubs/protobuf/google/protobuf" in str(path): # TODO: fix protobuf stubs
continue
if "stubs/dateparser/" in str(path): # TODO: fix dateparser
continue
with open(path) as f:
tree = ast.parse(f.read())