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

import hashlib
import os
import posixpath
import re
from __future__ import annotations
from importlib import import_module
from os import path
from typing import Any, IO
from urllib.parse import parse_qsl, quote_plus, urlencode, urlsplit, urlunsplit
from sphinx.errors import ExtensionError, FiletypeNotFoundError
from sphinx.locale import __
from sphinx.util import display as _display, exceptions as _exceptions, http_date as _http_date, index_entries as _index_entries, logging, osutil as _osutil
from sphinx.util.console import strip_colors
from sphinx.util.matching import patfilter
from sphinx.util.nodes import caption_ref_re, explicit_title_re, nested_parse_with_titles, split_explicit_title
from sphinx.util.osutil import SEP, copyfile, copytimes, ensuredir, make_filename, mtimes_of_files, os_path, relative_uri

"""Utility functions for Sphinx."""
logger = ...
ws_re: re.Pattern[str] = ...
url_re: re.Pattern[str] = ...
def docname_join(basedocname: str, docname: str) -> str:
    ...

def get_filetype(source_suffix: dict[str, str], filename: str) -> str:
    ...

class FilenameUniqDict(dict):
    """
    A dictionary that automatically generates unique names for its keys,
    interpreted as filenames, and keeps track of a set of docnames they
    appear in.  Used for images and downloadable files in the environment.
    """
    def __init__(self) -> None:
        ...
    
    def add_file(self, docname: str, newfile: str) -> str:
        ...
    
    def purge_doc(self, docname: str) -> None:
        ...
    
    def merge_other(self, docnames: set[str], other: dict[str, tuple[set[str], Any]]) -> None:
        ...
    
    def __getstate__(self) -> set[str]:
        ...
    
    def __setstate__(self, state: set[str]) -> None:
        ...
    


class DownloadFiles(dict):
    """A special dictionary for download files.

    .. important:: This class would be refactored in nearly future.
                   Hence don't hack this directly.
    """
    def add_file(self, docname: str, filename: str) -> str:
        ...
    
    def purge_doc(self, docname: str) -> None:
        ...
    
    def merge_other(self, docnames: set[str], other: dict[str, tuple[set[str], Any]]) -> None:
        ...
    


_coding_re = ...
class UnicodeDecodeErrorHandler:
    """Custom error handler for open() that warns and replaces."""
    def __init__(self, docname: str) -> None:
        ...
    
    def __call__(self, error: UnicodeDecodeError) -> tuple[str, int]:
        ...
    


class Tee:
    """
    File-like object writing to two streams.
    """
    def __init__(self, stream1: IO, stream2: IO) -> None:
        ...
    
    def write(self, text: str) -> None:
        ...
    
    def flush(self) -> None:
        ...
    


def parselinenos(spec: str, total: int) -> list[int]:
    """Parse a line number spec (such as "1,2,4-6") and return a list of
    wanted line numbers.
    """
    ...

def import_object(objname: str, source: str | None = ...) -> Any:
    """Import python object by qualname."""
    ...

def encode_uri(uri: str) -> str:
    ...

def isurl(url: str) -> bool:
    """Check *url* is URL or not."""
    ...

_DEPRECATED_OBJECTS = ...
def __getattr__(name): # -> ((filepath: str | PathLike[str], /) -> str) | ((chunk: Any) -> str) | ((iterable: Unknown, summary: str, color: str = 'darkgreen', length: int = 0, verbosity: int = 0, stringify_func: ((Any) -> str) = display_chunk) -> Unknown) | type[SkipProgressMessage] | type[progress_message] | ((epoch: float) -> str) | ((rfc1123: str) -> float) | ((app: Sphinx | None, exc: BaseException) -> str) | ((x: int = 1) -> str) | (() -> Pattern[str]) | ((entry_type: str, value: str) -> list[str]) | ((data: bytes = b'', **_kw: Unknown) -> _Hash):
    ...

