"""
This type stub file was generated by pyright.
"""

import numpy as np
from typing import TYPE_CHECKING, overload
from pandas._typing import ArrayLike, DtypeObj, IgnoreRaise
from pandas.core.dtypes.dtypes import ExtensionDtype
from pandas.core.arrays import DatetimeArray, ExtensionArray

"""
Functions for implementing 'astype' methods according to pandas conventions,
particularly ones that differ from numpy.
"""
if TYPE_CHECKING:
    ...
_dtype_obj = ...
@overload
def astype_nansafe(arr: np.ndarray, dtype: np.dtype, copy: bool = ..., skipna: bool = ...) -> np.ndarray:
    ...

@overload
def astype_nansafe(arr: np.ndarray, dtype: ExtensionDtype, copy: bool = ..., skipna: bool = ...) -> ExtensionArray:
    ...

def astype_nansafe(arr: np.ndarray, dtype: DtypeObj, copy: bool = ..., skipna: bool = ...) -> ArrayLike:
    """
    Cast the elements of an array to a given dtype a nan-safe manner.

    Parameters
    ----------
    arr : ndarray
    dtype : np.dtype or ExtensionDtype
    copy : bool, default True
        If False, a view will be attempted but may fail, if
        e.g. the item sizes don't align.
    skipna: bool, default False
        Whether or not we should skip NaN when casting as a string-type.

    Raises
    ------
    ValueError
        The dtype was a datetime64/timedelta64 dtype, but it had no unit.
    """
    ...

def astype_array(values: ArrayLike, dtype: DtypeObj, copy: bool = ...) -> ArrayLike:
    """
    Cast array (ndarray or ExtensionArray) to the new dtype.

    Parameters
    ----------
    values : ndarray or ExtensionArray
    dtype : dtype object
    copy : bool, default False
        copy if indicated

    Returns
    -------
    ndarray or ExtensionArray
    """
    ...

def astype_array_safe(values: ArrayLike, dtype, copy: bool = ..., errors: IgnoreRaise = ...) -> ArrayLike:
    """
    Cast array (ndarray or ExtensionArray) to the new dtype.

    This basically is the implementation for DataFrame/Series.astype and
    includes all custom logic for pandas (NaN-safety, converting str to object,
    not allowing )

    Parameters
    ----------
    values : ndarray or ExtensionArray
    dtype : str, dtype convertible
    copy : bool, default False
        copy if indicated
    errors : str, {'raise', 'ignore'}, default 'raise'
        - ``raise`` : allow exceptions to be raised
        - ``ignore`` : suppress exceptions. On error return original object

    Returns
    -------
    ndarray or ExtensionArray
    """
    ...

def astype_td64_unit_conversion(values: np.ndarray, dtype: np.dtype, copy: bool) -> np.ndarray:
    """
    By pandas convention, converting to non-nano timedelta64
    returns an int64-dtyped array with ints representing multiples
    of the desired timedelta unit.  This is essentially division.

    Parameters
    ----------
    values : np.ndarray[timedelta64[ns]]
    dtype : np.dtype
        timedelta64 with unit not-necessarily nano
    copy : bool

    Returns
    -------
    np.ndarray
    """
    ...

def astype_dt64_to_dt64tz(values: ArrayLike, dtype: DtypeObj, copy: bool, via_utc: bool = ...) -> DatetimeArray:
    ...

