Skip to content
Merged
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.1"
version = "1.4.2"
upstream-repository = "https://github.com/scrapinghub/dateparser"

[tool.stubtest]
Expand Down
1 change: 1 addition & 0 deletions stubs/dateparser/dateparser/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class _Settings(TypedDict, total=False): # noqa: Y049
RELATIVE_BASE: datetime.datetime
STRICT_PARSING: bool
REQUIRE_PARTS: list[Literal["day", "month", "year"]]
IGNORE_SURROUNDING_TEXT: bool
SKIP_TOKENS: list[str]
NORMALIZE: bool
RETURN_TIME_AS_PERIOD: bool
Expand Down
1 change: 1 addition & 0 deletions stubs/dateparser/dateparser/conf.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Settings:
RELATIVE_BASE: datetime.datetime
STRICT_PARSING: bool
REQUIRE_PARTS: list[Literal["day", "month", "year"]]
IGNORE_SURROUNDING_TEXT: bool
SKIP_TOKENS: list[str]
NORMALIZE: bool
RETURN_TIME_AS_PERIOD: bool
Expand Down
6 changes: 4 additions & 2 deletions stubs/dateparser/dateparser/date.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class _DateLocaleParser:
date_string: str,
date_formats: list[str] | tuple[str, ...] | AbstractSet[str] | None,
settings: Settings | None = None,
ignore_surrounding_text: bool = False,
) -> None: ...
@classmethod
def parse(
Expand All @@ -82,6 +83,7 @@ class _DateLocaleParser:
date_string: str,
date_formats: list[str] | tuple[str, ...] | AbstractSet[str] | None = None,
settings: Settings | None = None,
ignore_surrounding_text: bool = False,
) -> DateData: ...
def _parse(self) -> DateData | None: ...
def _try_timestamp(self) -> DateData: ...
Expand Down Expand Up @@ -140,7 +142,7 @@ class DateDataParser:
def get_date_tuple(
self, date_string: str, date_formats: list[str] | tuple[str, ...] | AbstractSet[str] | None = None
) -> _DateData: ...
def _get_applicable_locales(self, date_string: str) -> Iterator[Locale]: ...
def _is_applicable_locale(self, locale: Locale, date_string: str) -> bool: ...
def _get_applicable_locales(self, date_string: str, ignore_surrounding_text: bool = False) -> Iterator[Locale]: ...
def _is_applicable_locale(self, locale: Locale, date_string: str, ignore_surrounding_text: bool = False) -> bool: ...
@classmethod
def _get_locale_loader(cls: type[DateDataParser]) -> LocaleDataLoader: ...
16 changes: 14 additions & 2 deletions stubs/dateparser/dateparser/languages/locale.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,23 @@ class Locale:
shortname: str
info: OrderedDict[str, Incomplete]
def __init__(self, shortname: str, language_info: Mapping[Incomplete, Incomplete]) -> None: ...
def is_applicable(self, date_string: str, strip_timezone: bool = False, settings: Settings | None = None) -> bool: ...
def is_applicable(
self,
date_string: str,
strip_timezone: bool = False,
settings: Settings | None = None,
ignore_surrounding_text: bool = False,
) -> bool: ...
def count_applicability(self, text: str, strip_timezone: bool = False, settings: Settings | None = None) -> list[int]: ...
@staticmethod
def clean_dictionary(dictionary: Mapping[_K, _V], threshold: int = 2) -> Mapping[_K, _V]: ...
def translate(self, date_string: str, keep_formatting: bool = False, settings: Settings | None = None) -> str: ...
def translate(
self,
date_string: str,
keep_formatting: bool = False,
settings: Settings | None = None,
ignore_surrounding_text: bool = False,
) -> str: ...
def translate_search(self, search_string: str, settings: Settings | None = None) -> tuple[list[str], list[str]]: ...
def get_wordchars_for_detection(self, settings: Settings) -> set[str]: ...
def to_parserinfo(self, base_cls: type = ...): ...
2 changes: 2 additions & 0 deletions stubs/dateparser/dateparser/search/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def search_dates(
settings: Settings | dict[str, Any] | None,
add_detected_language: Literal[True],
detect_languages_function: _DetectLanguagesFunction | None = None,
strategy: Literal["split", "ngram"] = "split",
) -> list[tuple[str, datetime, str]] | None: ...
@overload
def search_dates(
Expand All @@ -21,4 +22,5 @@ def search_dates(
settings: Settings | dict[str, Any] | None = None,
add_detected_language: Literal[False] = False,
detect_languages_function: _DetectLanguagesFunction | None = None,
strategy: Literal["split", "ngram"] = "split",
) -> list[tuple[str, datetime]] | None: ...
18 changes: 18 additions & 0 deletions stubs/dateparser/dateparser/search/ngram_search.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import datetime
from _typeshed import Incomplete
from collections.abc import Set as AbstractSet
from logging import Logger

from dateparser.conf import Settings

logger: Logger

class _NgramDateSearch:
max_tokens: int
def __init__(self, max_tokens: int = 7) -> None: ...
def search_parse(
self,
languages: list[str] | tuple[str, ...] | AbstractSet[str] | None,
text: str,
settings: Settings | dict[str, Incomplete] | None,
) -> list[tuple[str, datetime.datetime]]: ...
3 changes: 2 additions & 1 deletion stubs/dateparser/dateparser/search/search.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import re
from _typeshed import Incomplete
from collections import OrderedDict
from collections.abc import Iterable, Sequence, Set as AbstractSet
from typing import Any, Final, TypedDict, type_check_only
from typing import Any, Final, Literal, TypedDict, type_check_only

from dateparser.conf import Settings
from dateparser.date import DateData, DateDataParser, _DetectLanguagesFunction
Expand Down Expand Up @@ -72,5 +72,6 @@ class DateSearchWithDetection:
languages: list[str] | tuple[str, ...] | AbstractSet[str] | None = None,
settings: Settings | dict[str, Any] | None = None,
detect_languages_function: _DetectLanguagesFunction | None = None,
strategy: Literal["split", "ngram"] = "split",
) -> _SearchDates: ...
def preprocess_text(self, text: str, languages: Iterable[str] | None) -> str: ...
1 change: 1 addition & 0 deletions stubs/dateparser/dateparser/timezone_parser.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class StaticTzInfo(tzinfo):

def pop_tz_offset_from_string(date_string: str, as_offset: bool = True) -> tuple[str, StaticTzInfo | str | None]: ...
def word_is_tz(word: str) -> bool: ...
def is_timezone_token(token: str) -> bool: ...
def convert_to_local_tz(datetime_obj: _DateTimeT, datetime_tz_offset: timedelta) -> _DateTimeT: ...
def build_tz_offsets(search_regex_parts: list[str]) -> Generator[tuple[str, dict[str, re.Pattern[str] | timedelta]]]: ...
def get_local_tz_offset() -> timedelta: ...
Expand Down