Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stubs/dateparser/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "1.4.2"
version = "1.4.3"
upstream-repository = "https://github.com/scrapinghub/dateparser"

[tool.stubtest]
Expand Down
2 changes: 1 addition & 1 deletion stubs/dateparser/dateparser/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ _default_parser: DateDataParser

@type_check_only
class _Settings(TypedDict, total=False): # noqa: Y049
DATE_ORDER: str
DATE_ORDER: Literal["DMY", "DYM", "MDY", "MYD", "YDM", "YMD"]
PREFER_LOCALE_DATE_ORDER: bool
TIMEZONE: str
TO_TIMEZONE: str
Expand Down
2 changes: 1 addition & 1 deletion stubs/dateparser/dateparser/conf.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ _R = TypeVar("_R")
class Settings:
# Next attributes are optional and may be missing.
# Please keep in sync with _Settings TypedDict
DATE_ORDER: str
DATE_ORDER: Literal["DMY", "DYM", "MDY", "MYD", "YDM", "YMD"]
PREFER_LOCALE_DATE_ORDER: bool
TIMEZONE: str
TO_TIMEZONE: str
Expand Down
6 changes: 5 additions & 1 deletion stubs/dateparser/dateparser/date_parser.pyi
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
from collections.abc import Callable
from datetime import datetime, tzinfo
from typing import Literal

from dateparser.conf import Settings

class DateParser:
def parse(
self,
date_string: str,
parse_method: Callable[[str, Settings, tzinfo | None], tuple[datetime, str]],
parse_method: Callable[
[str, Settings, tzinfo | None, Literal["DMY", "DYM", "MDY", "MYD", "YDM", "YMD"] | None], tuple[datetime, str]
],
settings: Settings | None = None,
date_order: Literal["DMY", "DYM", "MDY", "MYD", "YDM", "YMD"] | None = None,
) -> tuple[datetime, str]: ...

date_parser: DateParser
23 changes: 17 additions & 6 deletions stubs/dateparser/dateparser/parser.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ HOUR_MINUTE_REGEX: Final[re.Pattern[str]]
def no_space_parser_eligibile(datestring: str) -> bool: ...
def get_unresolved_attrs(parser_object: object) -> tuple[list[_Component], list[_Component]]: ...

date_order_chart: Final[dict[str, str]]
date_order_chart: Final[dict[Literal["DMY", "DYM", "MDY", "MYD", "YDM", "YMD"], str]]

@overload
def resolve_date_order(order: str, lst: Literal[True]) -> list[_Component]: ...
def resolve_date_order(order: Literal["DMY", "DYM", "MDY", "MYD", "YDM", "YMD"], lst: Literal[True]) -> list[_Component]: ...
@overload
def resolve_date_order(order: str, lst: Literal[False] | None = None) -> str: ...
def resolve_date_order(order: Literal["DMY", "DYM", "MDY", "MYD", "YDM", "YMD"], lst: Literal[False] | None = None) -> str: ...

class _time_parser:
time_directives: list[str]
Expand All @@ -37,7 +37,9 @@ class _no_spaces_parser:
date_formats: dict[str, list[str]]
def __init__(self, *args, **kwargs) -> None: ...
@classmethod
def parse(cls, datestring: str, settings: Settings) -> tuple[datetime.datetime, str]: ...
def parse(
cls, datestring: str, settings: Settings, date_order: Literal["DMY", "DYM", "MDY", "MYD", "YDM", "YMD"] | None = None
) -> tuple[datetime.datetime, str]: ...

class _parser:
alpha_directives: ClassVar[dict[str, list[str]]]
Expand All @@ -54,10 +56,19 @@ class _parser:
auto_order: list[str]
ordered_num_directives: OrderedDict[str, list[str]]

def __init__(self, tokens: Iterable[tuple[str, _TokenType]], settings: Settings) -> None: ...
def __init__(
self,
tokens: Iterable[tuple[str, _TokenType]],
settings: Settings,
date_order: Literal["DMY", "DYM", "MDY", "MYD", "YDM", "YMD"] | None = None,
) -> None: ...
@classmethod
def parse(
cls, datestring: str, settings: Settings, tz: datetime.tzinfo | None = None
cls,
datestring: str,
settings: Settings,
tz: datetime.tzinfo | None = None,
date_order: Literal["DMY", "DYM", "MDY", "MYD", "YDM", "YMD"] | None = None,
) -> tuple[datetime.datetime, str | None]: ...

class tokenizer:
Expand Down
5 changes: 2 additions & 3 deletions stubs/dateparser/dateparser/search/search.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ from dateparser.conf import Settings
from dateparser.date import DateData, DateDataParser, _DetectLanguagesFunction
from dateparser.languages.loader import LocaleDataLoader
from dateparser.languages.locale import Locale
from dateparser.search.text_detection import FullTextLanguageDetector
from dateparser.search.ngram_search import _NgramDateSearch

@type_check_only
class _SearchDates(TypedDict):
Expand All @@ -22,7 +22,6 @@ def date_is_relative(translation: str) -> bool: ...

class _ExactLanguageSearch:
loader: LocaleDataLoader
language: Locale | None
def __init__(self, loader: LocaleDataLoader) -> None: ...
def get_current_language(self, shortname: str) -> None: ...
def search(self, shortname: str, text: str, settings: Settings | None) -> tuple[list[str], list[str]]: ...
Expand Down Expand Up @@ -57,7 +56,7 @@ class DateSearchWithDetection:
loader: LocaleDataLoader
available_language_map: OrderedDict[str, Locale]
search: _ExactLanguageSearch
language_detector: FullTextLanguageDetector
ngram_search: _NgramDateSearch
def __init__(self) -> None: ...
def detect_language(
self,
Expand Down