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

from typing import TYPE_CHECKING, TypedDict
from typing_extensions import NotRequired, TypeAlias
from pathlib import Path

if TYPE_CHECKING:
    ...
PageHash: TypeAlias = str
PageName: TypeAlias = str
ScriptPath: TypeAlias = str
Icon: TypeAlias = str
class PageInfo(TypedDict):
    script_path: ScriptPath
    page_script_hash: PageHash
    icon: NotRequired[Icon]
    page_name: NotRequired[PageName]
    url_pathname: NotRequired[str]
    ...


def open_python_file(filename: str): # -> TextIO | TextIOWrapper[_WrappedBuffer]:
    """Open a read-only Python file taking proper care of its encoding.

    In Python 3, we would like all files to be opened with utf-8 encoding.
    However, some author like to specify PEP263 headers in their source files
    with their own encodings. In that case, we should respect the author's
    encoding.
    """
    ...

PAGE_FILENAME_REGEX = ...
def page_sort_key(script_path: Path) -> tuple[float, str]:
    ...

def page_icon_and_name(script_path: Path) -> tuple[str, str]:
    """Compute the icon and name of a page from its script path.

    This is *almost* the page name displayed in the nav UI, but it has
    underscores instead of spaces. The reason we do this is because having
    spaces in URLs both looks bad and is hard to deal with due to the need to
    URL-encode them. To solve this, we only swap the underscores for spaces
    right before we render page names.
    """
    ...

