mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-18 09:55:59 +08:00
Stubs for dateparser (#5778)
Stubgen and manual fixes. Co-authored-by: Akuli <akuviljanen17@gmail.com>
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
"stubs/caldav",
|
||||
"stubs/commonmark",
|
||||
"stubs/cryptography",
|
||||
"stubs/dateparser",
|
||||
"stubs/docutils",
|
||||
"stubs/Flask",
|
||||
"stubs/html5lib",
|
||||
|
||||
5
stubs/dateparser/@tests/stubtest_allowlist.txt
Normal file
5
stubs/dateparser/@tests/stubtest_allowlist.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
dateparser.calendars.hijri
|
||||
dateparser.calendars.hijri_parser
|
||||
dateparser.calendars.jalali
|
||||
dateparser.calendars.jalali_parser
|
||||
dateparser.search.detection.BaseLanguageDetector.iterate_applicable_languages
|
||||
@@ -1,2 +1 @@
|
||||
version = "0.1"
|
||||
python2 = true
|
||||
version = "1.0"
|
||||
|
||||
@@ -11,4 +11,3 @@ def parse(
|
||||
region: str | None = ...,
|
||||
settings: Mapping[str, Any] | None = ...,
|
||||
) -> datetime.datetime | None: ...
|
||||
def __getattr__(name: str) -> Any: ... # incomplete
|
||||
20
stubs/dateparser/dateparser/calendars/__init__.pyi
Normal file
20
stubs/dateparser/dateparser/calendars/__init__.pyi
Normal file
@@ -0,0 +1,20 @@
|
||||
from typing import Any
|
||||
|
||||
from dateparser.parser import _parser
|
||||
|
||||
class CalendarBase:
|
||||
parser: Any
|
||||
source: Any
|
||||
def __init__(self, source) -> None: ...
|
||||
def get_date(self): ...
|
||||
|
||||
class non_gregorian_parser(_parser):
|
||||
calendar_converter: Any
|
||||
default_year: Any
|
||||
default_month: Any
|
||||
default_day: Any
|
||||
non_gregorian_date_cls: Any
|
||||
@classmethod
|
||||
def to_latin(cls, source): ...
|
||||
@classmethod
|
||||
def parse(cls, datestring, settings): ...
|
||||
6
stubs/dateparser/dateparser/calendars/hijri.pyi
Normal file
6
stubs/dateparser/dateparser/calendars/hijri.pyi
Normal file
@@ -0,0 +1,6 @@
|
||||
from typing import Any
|
||||
|
||||
from dateparser.calendars import CalendarBase
|
||||
|
||||
class HijriCalendar(CalendarBase):
|
||||
parser: Any
|
||||
25
stubs/dateparser/dateparser/calendars/hijri_parser.pyi
Normal file
25
stubs/dateparser/dateparser/calendars/hijri_parser.pyi
Normal file
@@ -0,0 +1,25 @@
|
||||
from typing import Any
|
||||
|
||||
from dateparser.calendars import non_gregorian_parser
|
||||
|
||||
class hijri:
|
||||
@classmethod
|
||||
def to_gregorian(cls, year: Any | None = ..., month: Any | None = ..., day: Any | None = ...): ...
|
||||
@classmethod
|
||||
def from_gregorian(cls, year: Any | None = ..., month: Any | None = ..., day: Any | None = ...): ...
|
||||
@classmethod
|
||||
def month_length(cls, year, month): ...
|
||||
|
||||
class HijriDate:
|
||||
year: Any
|
||||
month: Any
|
||||
day: Any
|
||||
def __init__(self, year, month, day) -> None: ...
|
||||
def weekday(self): ...
|
||||
|
||||
class hijri_parser(non_gregorian_parser):
|
||||
calendar_converter: Any
|
||||
default_year: int
|
||||
default_month: int
|
||||
default_day: int
|
||||
non_gregorian_date_cls: Any
|
||||
6
stubs/dateparser/dateparser/calendars/jalali.pyi
Normal file
6
stubs/dateparser/dateparser/calendars/jalali.pyi
Normal file
@@ -0,0 +1,6 @@
|
||||
from typing import Any
|
||||
|
||||
from . import CalendarBase
|
||||
|
||||
class JalaliCalendar(CalendarBase):
|
||||
parser: Any
|
||||
17
stubs/dateparser/dateparser/calendars/jalali_parser.pyi
Normal file
17
stubs/dateparser/dateparser/calendars/jalali_parser.pyi
Normal file
@@ -0,0 +1,17 @@
|
||||
from typing import Any
|
||||
|
||||
from dateparser.calendars import non_gregorian_parser
|
||||
|
||||
class PersianDate:
|
||||
year: Any
|
||||
month: Any
|
||||
day: Any
|
||||
def __init__(self, year, month, day) -> None: ...
|
||||
def weekday(self): ...
|
||||
|
||||
class jalali_parser(non_gregorian_parser):
|
||||
calendar_converter: Any
|
||||
default_year: int
|
||||
default_month: int
|
||||
default_day: int
|
||||
non_gregorian_date_cls: Any
|
||||
16
stubs/dateparser/dateparser/conf.pyi
Normal file
16
stubs/dateparser/dateparser/conf.pyi
Normal file
@@ -0,0 +1,16 @@
|
||||
from typing import Any
|
||||
|
||||
class Settings:
|
||||
def __new__(cls, *args, **kw) -> Settings: ...
|
||||
def __init__(self, settings: Any | None = ...) -> None: ...
|
||||
@classmethod
|
||||
def get_key(cls, settings: Any | None = ...): ...
|
||||
def replace(self, mod_settings: Any | None = ..., **kwds): ...
|
||||
|
||||
settings: Any
|
||||
|
||||
def apply_settings(f): ...
|
||||
|
||||
class SettingValidationError(ValueError): ...
|
||||
|
||||
def check_settings(settings) -> None: ...
|
||||
0
stubs/dateparser/dateparser/data/__init__.pyi
Normal file
0
stubs/dateparser/dateparser/data/__init__.pyi
Normal file
4
stubs/dateparser/dateparser/data/languages_info.pyi
Normal file
4
stubs/dateparser/dateparser/data/languages_info.pyi
Normal file
@@ -0,0 +1,4 @@
|
||||
from typing import Any
|
||||
|
||||
language_order: Any
|
||||
language_locale_dict: Any
|
||||
56
stubs/dateparser/dateparser/date.pyi
Normal file
56
stubs/dateparser/dateparser/date.pyi
Normal file
@@ -0,0 +1,56 @@
|
||||
from typing import Any
|
||||
|
||||
APOSTROPHE_LOOK_ALIKE_CHARS: Any
|
||||
RE_NBSP: Any
|
||||
RE_SPACES: Any
|
||||
RE_TRIM_SPACES: Any
|
||||
RE_TRIM_COLONS: Any
|
||||
RE_SANITIZE_SKIP: Any
|
||||
RE_SANITIZE_RUSSIAN: Any
|
||||
RE_SANITIZE_PERIOD: Any
|
||||
RE_SANITIZE_ON: Any
|
||||
RE_SANITIZE_APOSTROPHE: Any
|
||||
RE_SEARCH_TIMESTAMP: Any
|
||||
|
||||
def sanitize_spaces(date_string): ...
|
||||
def date_range(begin, end, **kwargs) -> None: ...
|
||||
def get_intersecting_periods(low, high, period: str = ...) -> None: ...
|
||||
def sanitize_date(date_string): ...
|
||||
def get_date_from_timestamp(date_string, settings): ...
|
||||
def parse_with_formats(date_string, date_formats, settings): ...
|
||||
|
||||
class _DateLocaleParser:
|
||||
locale: Any
|
||||
date_string: Any
|
||||
date_formats: Any
|
||||
def __init__(self, locale, date_string, date_formats, settings: Any | None = ...) -> None: ...
|
||||
@classmethod
|
||||
def parse(cls, locale, date_string, date_formats: Any | None = ..., settings: Any | None = ...): ...
|
||||
|
||||
class DateData:
|
||||
date_obj: Any
|
||||
period: Any
|
||||
locale: Any
|
||||
def __init__(self, *, date_obj: Any | None = ..., period: Any | None = ..., locale: Any | None = ...) -> None: ...
|
||||
def __getitem__(self, k): ...
|
||||
def __setitem__(self, k, v) -> None: ...
|
||||
|
||||
class DateDataParser:
|
||||
locale_loader: Any
|
||||
try_previous_locales: Any
|
||||
use_given_order: Any
|
||||
languages: Any
|
||||
locales: Any
|
||||
region: Any
|
||||
previous_locales: Any
|
||||
def __init__(
|
||||
self,
|
||||
languages: Any | None = ...,
|
||||
locales: Any | None = ...,
|
||||
region: Any | None = ...,
|
||||
try_previous_locales: bool = ...,
|
||||
use_given_order: bool = ...,
|
||||
settings: Any | None = ...,
|
||||
) -> None: ...
|
||||
def get_date_data(self, date_string, date_formats: Any | None = ...): ...
|
||||
def get_date_tuple(self, *args, **kwargs): ...
|
||||
6
stubs/dateparser/dateparser/date_parser.pyi
Normal file
6
stubs/dateparser/dateparser/date_parser.pyi
Normal file
@@ -0,0 +1,6 @@
|
||||
from typing import Any
|
||||
|
||||
class DateParser:
|
||||
def parse(self, date_string, parse_method, settings: Any | None = ...): ...
|
||||
|
||||
date_parser: Any
|
||||
11
stubs/dateparser/dateparser/freshness_date_parser.pyi
Normal file
11
stubs/dateparser/dateparser/freshness_date_parser.pyi
Normal file
@@ -0,0 +1,11 @@
|
||||
from typing import Any
|
||||
|
||||
PATTERN: Any
|
||||
|
||||
class FreshnessDateDataParser:
|
||||
def get_local_tz(self): ...
|
||||
def parse(self, date_string, settings): ...
|
||||
def get_kwargs(self, date_string): ...
|
||||
def get_date_data(self, date_string, settings: Any | None = ...): ...
|
||||
|
||||
freshness_date_parser: Any
|
||||
0
stubs/dateparser/dateparser/languages/__init__.pyi
Normal file
0
stubs/dateparser/dateparser/languages/__init__.pyi
Normal file
23
stubs/dateparser/dateparser/languages/dictionary.pyi
Normal file
23
stubs/dateparser/dateparser/languages/dictionary.pyi
Normal file
@@ -0,0 +1,23 @@
|
||||
from typing import Any
|
||||
|
||||
PARSER_HARDCODED_TOKENS: Any
|
||||
PARSER_KNOWN_TOKENS: Any
|
||||
ALWAYS_KEEP_TOKENS: Any
|
||||
KNOWN_WORD_TOKENS: Any
|
||||
PARENTHESES_PATTERN: Any
|
||||
NUMERAL_PATTERN: Any
|
||||
KEEP_TOKEN_PATTERN: Any
|
||||
|
||||
class UnknownTokenError(Exception): ...
|
||||
|
||||
class Dictionary:
|
||||
info: Any
|
||||
def __init__(self, locale_info, settings: Any | None = ...) -> None: ...
|
||||
def __contains__(self, key): ...
|
||||
def __getitem__(self, key): ...
|
||||
def __iter__(self) -> Any: ...
|
||||
def are_tokens_valid(self, tokens): ...
|
||||
def split(self, string, keep_formatting: bool = ...): ...
|
||||
|
||||
class NormalizedDictionary(Dictionary):
|
||||
def __init__(self, locale_info, settings: Any | None = ...) -> None: ...
|
||||
27
stubs/dateparser/dateparser/languages/loader.pyi
Normal file
27
stubs/dateparser/dateparser/languages/loader.pyi
Normal file
@@ -0,0 +1,27 @@
|
||||
from collections import OrderedDict
|
||||
from typing import Any, Iterator, List, Optional, Union
|
||||
|
||||
from .locale import Locale
|
||||
|
||||
LOCALE_SPLIT_PATTERN: Any
|
||||
|
||||
class LocaleDataLoader:
|
||||
def get_locale_map(
|
||||
self,
|
||||
languages: Optional[List[str]] = ...,
|
||||
locales: Optional[List[str]] = ...,
|
||||
region: str | None = ...,
|
||||
use_given_order: bool = ...,
|
||||
allow_conflicting_locales: bool = ...,
|
||||
) -> OrderedDict[str, Union[List[Any], str, int]]: ...
|
||||
def get_locales(
|
||||
self,
|
||||
languages: Optional[List[str]] = ...,
|
||||
locales: Optional[List[str]] = ...,
|
||||
region: str | None = ...,
|
||||
use_given_order: bool = ...,
|
||||
allow_conflicting_locales: bool = ...,
|
||||
) -> Iterator[Locale]: ...
|
||||
def get_locale(self, shortname: str) -> Locale: ...
|
||||
|
||||
default_loader: Any
|
||||
17
stubs/dateparser/dateparser/languages/locale.pyi
Normal file
17
stubs/dateparser/dateparser/languages/locale.pyi
Normal file
@@ -0,0 +1,17 @@
|
||||
from typing import Any
|
||||
|
||||
DIGIT_GROUP_PATTERN: Any
|
||||
NUMERAL_PATTERN: Any
|
||||
|
||||
class Locale:
|
||||
shortname: Any
|
||||
info: Any
|
||||
def __init__(self, shortname, language_info) -> None: ...
|
||||
def is_applicable(self, date_string, strip_timezone: bool = ..., settings: Any | None = ...): ...
|
||||
def count_applicability(self, text, strip_timezone: bool = ..., settings: Any | None = ...): ...
|
||||
@staticmethod
|
||||
def clean_dictionary(dictionary, threshold: int = ...): ...
|
||||
def translate(self, date_string, keep_formatting: bool = ..., settings: Any | None = ...): ...
|
||||
def translate_search(self, search_string, settings: Any | None = ...): ...
|
||||
def get_wordchars_for_detection(self, settings): ...
|
||||
def to_parserinfo(self, base_cls=...): ...
|
||||
9
stubs/dateparser/dateparser/languages/validation.pyi
Normal file
9
stubs/dateparser/dateparser/languages/validation.pyi
Normal file
@@ -0,0 +1,9 @@
|
||||
from typing import Any
|
||||
|
||||
class LanguageValidator:
|
||||
logger: Any
|
||||
VALID_KEYS: Any
|
||||
@classmethod
|
||||
def get_logger(cls): ...
|
||||
@classmethod
|
||||
def validate_info(cls, language_id, info): ...
|
||||
51
stubs/dateparser/dateparser/parser.pyi
Normal file
51
stubs/dateparser/dateparser/parser.pyi
Normal file
@@ -0,0 +1,51 @@
|
||||
from typing import Any
|
||||
|
||||
NSP_COMPATIBLE: Any
|
||||
MERIDIAN: Any
|
||||
MICROSECOND: Any
|
||||
EIGHT_DIGIT: Any
|
||||
HOUR_MINUTE_REGEX: Any
|
||||
|
||||
def no_space_parser_eligibile(datestring): ...
|
||||
def get_unresolved_attrs(parser_object): ...
|
||||
|
||||
date_order_chart: Any
|
||||
|
||||
def resolve_date_order(order, lst: Any | None = ...): ...
|
||||
|
||||
class _time_parser:
|
||||
time_directives: Any
|
||||
def __call__(self, timestring): ...
|
||||
|
||||
time_parser: Any
|
||||
|
||||
class _no_spaces_parser:
|
||||
period: Any
|
||||
date_formats: Any
|
||||
def __init__(self, *args, **kwargs): ...
|
||||
@classmethod
|
||||
def parse(cls, datestring, settings): ...
|
||||
|
||||
class _parser:
|
||||
alpha_directives: Any
|
||||
num_directives: Any
|
||||
settings: Any
|
||||
tokens: Any
|
||||
filtered_tokens: Any
|
||||
unset_tokens: Any
|
||||
day: Any
|
||||
month: Any
|
||||
year: Any
|
||||
time: Any
|
||||
auto_order: Any
|
||||
ordered_num_directives: Any
|
||||
def __init__(self, tokens, settings): ...
|
||||
@classmethod
|
||||
def parse(cls, datestring, settings): ...
|
||||
|
||||
class tokenizer:
|
||||
digits: str
|
||||
letters: str
|
||||
instream: Any
|
||||
def __init__(self, ds) -> None: ...
|
||||
def tokenize(self) -> None: ...
|
||||
23
stubs/dateparser/dateparser/search/__init__.pyi
Normal file
23
stubs/dateparser/dateparser/search/__init__.pyi
Normal file
@@ -0,0 +1,23 @@
|
||||
import sys
|
||||
from datetime import datetime
|
||||
from typing import Any, List, Mapping, Optional, Set, Tuple, Union, overload
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
from typing import Literal
|
||||
else:
|
||||
from typing_extensions import Literal
|
||||
|
||||
@overload
|
||||
def search_dates(
|
||||
text: str,
|
||||
languages: Optional[Union[List[str], Tuple[str], Set[str]]],
|
||||
settings: Optional[Mapping[Any, Any]],
|
||||
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]] = ...,
|
||||
add_detected_language: Literal[False] = ...,
|
||||
) -> List[Tuple[str, datetime]]: ...
|
||||
17
stubs/dateparser/dateparser/search/detection.pyi
Normal file
17
stubs/dateparser/dateparser/search/detection.pyi
Normal file
@@ -0,0 +1,17 @@
|
||||
from typing import Any
|
||||
|
||||
class BaseLanguageDetector:
|
||||
languages: Any
|
||||
def __init__(self, languages) -> None: ...
|
||||
def iterate_applicable_languages(self, date_string, modify: bool = ..., settings: Any | None = ...) -> None: ...
|
||||
|
||||
class AutoDetectLanguage(BaseLanguageDetector):
|
||||
language_pool: Any
|
||||
allow_redetection: Any
|
||||
def __init__(self, languages, allow_redetection: bool = ...) -> None: ...
|
||||
languages: Any
|
||||
def iterate_applicable_languages(self, date_string, modify: bool = ..., settings: Any | None = ...) -> None: ...
|
||||
|
||||
class ExactLanguages(BaseLanguageDetector):
|
||||
def __init__(self, languages) -> None: ...
|
||||
def iterate_applicable_languages(self, date_string, modify: bool = ..., settings: Any | None = ...) -> None: ...
|
||||
29
stubs/dateparser/dateparser/search/search.pyi
Normal file
29
stubs/dateparser/dateparser/search/search.pyi
Normal file
@@ -0,0 +1,29 @@
|
||||
from typing import Any
|
||||
|
||||
RELATIVE_REG: Any
|
||||
|
||||
def date_is_relative(translation): ...
|
||||
|
||||
class _ExactLanguageSearch:
|
||||
loader: Any
|
||||
language: Any
|
||||
def __init__(self, loader) -> None: ...
|
||||
def get_current_language(self, shortname) -> None: ...
|
||||
def search(self, shortname, text, settings): ...
|
||||
@staticmethod
|
||||
def set_relative_base(substring, already_parsed): ...
|
||||
def choose_best_split(self, possible_parsed_splits, possible_substrings_splits): ...
|
||||
def split_by(self, item, original, splitter): ...
|
||||
def split_if_not_parsed(self, item, original): ...
|
||||
def parse_item(self, parser, item, translated_item, parsed, need_relative_base): ...
|
||||
def parse_found_objects(self, parser, to_parse, original, translated, settings): ...
|
||||
def search_parse(self, shortname, text, settings): ...
|
||||
|
||||
class DateSearchWithDetection:
|
||||
loader: Any
|
||||
available_language_map: Any
|
||||
search: Any
|
||||
def __init__(self) -> None: ...
|
||||
language_detector: Any
|
||||
def detect_language(self, text, languages): ...
|
||||
def search_dates(self, text, languages: Any | None = ..., settings: Any | None = ...): ...
|
||||
11
stubs/dateparser/dateparser/search/text_detection.pyi
Normal file
11
stubs/dateparser/dateparser/search/text_detection.pyi
Normal file
@@ -0,0 +1,11 @@
|
||||
from typing import Any
|
||||
|
||||
from dateparser.search.detection import BaseLanguageDetector
|
||||
|
||||
class FullTextLanguageDetector(BaseLanguageDetector):
|
||||
languages: Any
|
||||
language_unique_chars: Any
|
||||
language_chars: Any
|
||||
def __init__(self, languages) -> None: ...
|
||||
def get_unique_characters(self, settings) -> None: ...
|
||||
def character_check(self, date_string, settings) -> None: ...
|
||||
18
stubs/dateparser/dateparser/timezone_parser.pyi
Normal file
18
stubs/dateparser/dateparser/timezone_parser.pyi
Normal file
@@ -0,0 +1,18 @@
|
||||
from datetime import tzinfo
|
||||
from typing import Any
|
||||
|
||||
class StaticTzInfo(tzinfo):
|
||||
def __init__(self, name, offset) -> None: ...
|
||||
def tzname(self, dt): ...
|
||||
def utcoffset(self, dt): ...
|
||||
def dst(self, dt): ...
|
||||
def localize(self, dt, is_dst: bool = ...): ...
|
||||
def __getinitargs__(self): ...
|
||||
|
||||
def pop_tz_offset_from_string(date_string, as_offset: bool = ...): ...
|
||||
def word_is_tz(word): ...
|
||||
def convert_to_local_tz(datetime_obj, datetime_tz_offset): ...
|
||||
def build_tz_offsets(search_regex_parts): ...
|
||||
def get_local_tz_offset(): ...
|
||||
|
||||
local_tz_offset: Any
|
||||
3
stubs/dateparser/dateparser/timezones.pyi
Normal file
3
stubs/dateparser/dateparser/timezones.pyi
Normal file
@@ -0,0 +1,3 @@
|
||||
from typing import Any
|
||||
|
||||
timezone_info_list: Any
|
||||
21
stubs/dateparser/dateparser/utils/__init__.pyi
Normal file
21
stubs/dateparser/dateparser/utils/__init__.pyi
Normal file
@@ -0,0 +1,21 @@
|
||||
from collections import OrderedDict
|
||||
from typing import Any, List, Mapping, Union
|
||||
|
||||
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]]]: ...
|
||||
def find_date_separator(format) -> Any: ...
|
||||
def localize_timezone(date_time, tz_string): ...
|
||||
def apply_tzdatabase_timezone(date_time, pytz_string): ...
|
||||
def apply_dateparser_timezone(utc_datetime, offset_or_timezone_abb): ...
|
||||
def apply_timezone(date_time, tz_string): ...
|
||||
def apply_timezone_from_settings(date_obj, settings): ...
|
||||
def get_last_day_of_month(year, month): ...
|
||||
def get_previous_leap_year(year): ...
|
||||
def get_next_leap_year(year): ...
|
||||
def set_correct_day_from_settings(date_obj, settings, current_day: Any | None = ...): ...
|
||||
def registry(cls): ...
|
||||
def get_logger() -> Any: ...
|
||||
def setup_logging() -> None: ...
|
||||
8
stubs/dateparser/dateparser/utils/strptime.pyi
Normal file
8
stubs/dateparser/dateparser/utils/strptime.pyi
Normal file
@@ -0,0 +1,8 @@
|
||||
from datetime import datetime
|
||||
from typing import Any
|
||||
|
||||
TIME_MATCHER: Any
|
||||
MS_SEARCHER: Any
|
||||
|
||||
def patch_strptime() -> Any: ...
|
||||
def strptime(date_string, format) -> datetime: ...
|
||||
0
stubs/dateparser/dateparser_data/__init__.pyi
Normal file
0
stubs/dateparser/dateparser_data/__init__.pyi
Normal file
4
stubs/dateparser/dateparser_data/settings.pyi
Normal file
4
stubs/dateparser/dateparser_data/settings.pyi
Normal file
@@ -0,0 +1,4 @@
|
||||
from typing import Any
|
||||
|
||||
default_parsers: Any
|
||||
settings: Any
|
||||
Reference in New Issue
Block a user