You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

202 lines
4.5 KiB
Python

"""
This type stub file was generated by pyright.
"""
import sys
from datetime import datetime, timedelta, tzinfo
"""This module contains several handy functions primarily meant for internal use."""
__all__ = ("asbool", "asint", "astimezone", "check_callable_args", "convert_to_datetime", "datetime_ceil", "datetime_to_utc_timestamp", "get_callable_name", "localize", "maybe_ref", "normalize", "obj_to_ref", "ref_to_obj", "undefined", "utc_timestamp_to_datetime")
if sys.version_info < (3, 14):
...
else:
...
if sys.version_info < (3, 9):
...
else:
...
UTC = ...
class _Undefined:
def __nonzero__(self): # -> Literal[False]:
...
def __bool__(self): # -> Literal[False]:
...
def __repr__(self): # -> Literal['<undefined>']:
...
undefined = ...
def asint(text): # -> int | None:
"""
Safely converts a string to an integer, returning ``None`` if the string is ``None``.
:type text: str
:rtype: int
"""
...
def asbool(obj): # -> bool:
"""
Interprets an object as a boolean value.
:rtype: bool
"""
...
def astimezone(obj): # -> timezone | ZoneInfo | tzinfo | None:
"""
Interprets an object as a timezone.
:rtype: tzinfo
"""
...
def asdate(obj): # -> date:
...
_DATE_REGEX = ...
def convert_to_datetime(input, tz, arg_name): # -> datetime | None:
"""
Converts the given object to a timezone aware datetime object.
If a timezone aware datetime object is passed, it is returned unmodified.
If a native datetime object is passed, it is given the specified timezone.
If the input is a string, it is parsed as a datetime with the given timezone.
Date strings are accepted in three different forms: date only (Y-m-d), date with
time (Y-m-d H:M:S) or with date+time with microseconds (Y-m-d H:M:S.micro).
Additionally you can override the time zone by giving a specific offset in the
format specified by ISO 8601: Z (UTC), +HH:MM or -HH:MM.
:param str|datetime input: the datetime or string to convert to a timezone aware
datetime
:param datetime.tzinfo tz: timezone to interpret ``input`` in
:param str arg_name: the name of the argument (used in an error message)
:rtype: datetime
"""
...
def datetime_to_utc_timestamp(timeval): # -> None:
"""
Converts a datetime instance to a timestamp.
:type timeval: datetime
:rtype: float
"""
...
def utc_timestamp_to_datetime(timestamp): # -> datetime | None:
"""
Converts the given timestamp to a datetime instance.
:type timestamp: float
:rtype: datetime
"""
...
def timedelta_seconds(delta):
"""
Converts the given timedelta to seconds.
:type delta: timedelta
:rtype: float
"""
...
def datetime_ceil(dateval): # -> datetime:
"""
Rounds the given datetime object upwards.
:type dateval: datetime
"""
...
def datetime_utc_add(dateval: datetime, tdelta: timedelta) -> datetime:
"""
Adds an timedelta to a datetime in UTC for correct datetime arithmetic across
Daylight Saving Time changes
:param dateval: The date to add to
:type dateval: datetime
:param operand: The timedelta to add to the datetime
:type operand: timedelta
:return: The sum of the datetime and the timedelta
:rtype: datetime
"""
...
def datetime_repr(dateval): # -> Literal['None']:
...
def timezone_repr(timezone: tzinfo) -> str:
...
def get_callable_name(func): # -> str:
"""
Returns the best available display name for the given function/callable.
:rtype: str
"""
...
def obj_to_ref(obj): # -> str:
"""
Returns the path to the given callable.
:rtype: str
:raises TypeError: if the given object is not callable
:raises ValueError: if the given object is a :class:`~functools.partial`, lambda or a nested
function
"""
...
def ref_to_obj(ref): # -> Any:
"""
Returns the object pointed to by ``ref``.
:type ref: str
"""
...
def maybe_ref(ref): # -> Any:
"""
Returns the object that the given reference points to, if it is indeed a reference.
If it is not a reference, the object is returned as-is.
"""
...
def check_callable_args(func, args, kwargs): # -> None:
"""
Ensures that the given callable can be called with the given arguments.
:type args: tuple
:type kwargs: dict
"""
...
def iscoroutinefunction_partial(f): # -> bool:
...
def normalize(dt): # -> datetime:
...
def localize(dt, tzinfo): # -> datetime:
...