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

import io
import os
import sys
from typing import Any, AnyStr, Optional, Union, overload

"""Helper classes use for fake file system implementation."""
AnyString = Union[str, bytes]
AnyPath = Union[AnyStr, "os.PathLike[AnyStr]"]
IS_PYPY = ...
IS_WIN = ...
IN_DOCKER = ...
PERM_READ = ...
PERM_WRITE = ...
PERM_EXE = ...
PERM_DEF = ...
PERM_DEF_FILE = ...
PERM_ALL = ...
if sys.platform == "win32": ...
else:
    USER_ID = ...
    GROUP_ID = ...

def set_uid(uid: int) -> None:
    """Set the global user id. This is used as st_uid for new files
    and to differentiate between a normal user and the root user (uid 0).
    For the root user, some permission restrictions are ignored.

    Args:
        uid: (int) the user ID of the user calling the file system functions.
    """
    ...

def set_gid(gid: int) -> None:
    """Set the global group id. This is only used to set st_gid for new files,
    no permission checks are performed.

    Args:
        gid: (int) the group ID of the user calling the file system functions.
    """
    ...

def reset_ids() -> None:
    """Set the global user ID and group ID back to default values."""
    ...

def is_root() -> bool:
    """Return True if the current user is the root user."""
    ...

def is_int_type(val: Any) -> bool:
    """Return True if `val` is of integer type."""
    ...

def is_byte_string(val: Any) -> bool:
    """Return True if `val` is a bytes-like object, False for a unicode
    string.
    """
    ...

def is_unicode_string(val: Any) -> bool:
    """Return True if `val` is a unicode string, False for a bytes-like
    object.
    """
    ...

@overload
def make_string_path(dir_name: AnyStr) -> AnyStr: ...
@overload
def make_string_path(dir_name: os.PathLike) -> str: ...
def make_string_path(dir_name: AnyPath) -> AnyStr: ...
def to_string(path: Union[AnyStr, Union[str, bytes]]) -> str:
    """Return the string representation of a byte string using the preferred
    encoding, or the string itself if path is a str.
    """
    ...

def to_bytes(path: Union[AnyStr, Union[str, bytes]]) -> bytes:
    """Return the bytes representation of a string using the preferred
    encoding, or the byte string itself if path is a byte string.
    """
    ...

def join_strings(s1: AnyStr, s2: AnyStr) -> AnyStr:
    """This is a bit of a hack to satisfy mypy - may be refactored."""
    ...

def real_encoding(encoding: Optional[str]) -> Optional[str]:
    """Since Python 3.10, the new function ``io.text_encoding`` returns
    "locale" as the encoding if None is defined. This will be handled
    as no encoding in pyfakefs.
    """
    ...

def now(): ...
@overload
def matching_string(matched: bytes, string: AnyStr) -> bytes: ...
@overload
def matching_string(matched: str, string: AnyStr) -> str: ...
@overload
def matching_string(matched: AnyStr, string: None) -> None: ...
def matching_string(matched: AnyStr, string: Optional[AnyStr]) -> Optional[AnyString]:
    """Return the string as byte or unicode depending
    on the type of matched, assuming string is an ASCII string.
    """
    ...

class FakeStatResult:
    """Mimics os.stat_result for use as return type of `stat()` and similar.
    This is needed as `os.stat_result` has no possibility to set
    nanosecond times directly.
    """

    def __init__(
        self,
        is_windows: bool,
        user_id: int,
        group_id: int,
        initial_time: Optional[float] = ...,
    ) -> None: ...
    def __eq__(self, other: Any) -> bool: ...
    def __ne__(self, other: Any) -> bool: ...
    def copy(self) -> FakeStatResult:
        """Return a copy where the float usage is hard-coded to mimic the
        behavior of the real os.stat_result.
        """
        ...
    def set_from_stat_result(self, stat_result: os.stat_result) -> None:
        """Set values from a real os.stat_result.
        Note: values that are controlled by the fake filesystem are not set.
        This includes st_ino, st_dev and st_nlink.
        """
        ...
    @property
    def st_ctime(self) -> Union[int, float]:
        """Return the creation time in seconds."""
        ...
    @st_ctime.setter
    def st_ctime(self, val: Union[int, float]) -> None:
        """Set the creation time in seconds."""
        ...
    @property
    def st_atime(self) -> Union[int, float]:
        """Return the access time in seconds."""
        ...
    @st_atime.setter
    def st_atime(self, val: Union[int, float]) -> None:
        """Set the access time in seconds."""
        ...
    @property
    def st_mtime(self) -> Union[int, float]:
        """Return the modification time in seconds."""
        ...
    @st_mtime.setter
    def st_mtime(self, val: Union[int, float]) -> None:
        """Set the modification time in seconds."""
        ...
    @property
    def st_size(self) -> int: ...
    @st_size.setter
    def st_size(self, val: int) -> None: ...
    @property
    def st_blocks(self) -> int:
        """Return the number of 512-byte blocks allocated for the file.
        Assumes a page size of 4096 (matches most systems).
        Ignores that this may not be available under some systems,
        and that the result may differ if the file has holes.
        """
        ...
    @property
    def st_file_attributes(self) -> int: ...
    @property
    def st_reparse_tag(self) -> int: ...
    def __getitem__(self, item: int) -> Optional[int]:
        """Implement item access to mimic `os.stat_result` behavior."""
        ...
    @property
    def st_atime_ns(self) -> int:
        """Return the access time in nanoseconds."""
        ...
    @st_atime_ns.setter
    def st_atime_ns(self, val: int) -> None:
        """Set the access time in nanoseconds."""
        ...
    @property
    def st_mtime_ns(self) -> int:
        """Return the modification time in nanoseconds."""
        ...
    @st_mtime_ns.setter
    def st_mtime_ns(self, val: int) -> None:
        """Set the modification time of the fake file in nanoseconds."""
        ...
    @property
    def st_ctime_ns(self) -> int:
        """Return the creation time in nanoseconds."""
        ...
    @st_ctime_ns.setter
    def st_ctime_ns(self, val: int) -> None:
        """Set the creation time of the fake file in nanoseconds."""
        ...

class BinaryBufferIO(io.BytesIO):
    """Stream class that handles byte contents for files."""

    def __init__(self, contents: Optional[bytes]) -> None: ...
    def putvalue(self, value: bytes) -> None: ...

class TextBufferIO(io.TextIOWrapper):
    """Stream class that handles Python string contents for files."""

    def __init__(
        self,
        contents: Optional[bytes] = ...,
        newline: Optional[str] = ...,
        encoding: Optional[str] = ...,
        errors: str = ...,
    ) -> None: ...
    def getvalue(self) -> bytes: ...
    def putvalue(self, value: bytes) -> None: ...
