from __future__ import annotations

from collections.abc import Callable, Collection, Iterator
from typing import Any, Literal, TypeVar, override

import numpy.typing as npt

from ..h5g import GroupID
from .attrs import AttributeManager
from .base import HLObject, MutableMappingHDF5
from .dataset import Dataset
from .datatype import Datatype

T = TypeVar("T")

class Group(HLObject, MutableMappingHDF5[str, "Group" | Dataset | Datatype]):
    def __init__(self, bind: GroupID) -> None: ...
    @override
    def __delitem__(self, name: str) -> None: ...
    def require_group(self, name: str) -> Group: ...
    @override
    def __getitem__(self, name: str | slice | tuple[()]) -> Group | Dataset | Datatype: ...
    @override
    def __setitem__(self, name: str, obj: Any) -> None: ...
    @override
    def __iter__(self) -> Iterator[str]: ...
    @override
    def __len__(self) -> int: ...
    @property
    @override
    def attrs(self) -> AttributeManager: ...
    def create_group(self, name: str, track_order: bool | None = None) -> Group: ...
    def create_dataset(
        self,
        name: str | None,
        shape: int | tuple[()] | tuple[int | None, ...] | None = None,
        dtype: npt.DTypeLike | None = None,
        data: Collection[Any] | None = None,
        **kwds: Any,
    ) -> Dataset: ...
    @property
    @override
    def id(self) -> GroupID: ...
    def move(self, source: str, dest: str) -> None: ...
    @property
    def mode(self) -> Literal["r", "r+"]: ...
    @property
    def parent(self) -> Group: ...
    def visit(self, callback: Callable[[str], T]) -> T: ...
    def visititems(self, callback: Callable[[str, Group | Dataset], T]) -> T: ...
