Skip to content

Commit

Permalink
TYP: Add basic h5py annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
BvB93 committed Sep 28, 2022
1 parent e230b5a commit c7a3190
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ files = ["nanoqm", "typings"]

[[tool.mypy.overrides]]
module = [
"h5py.*",
"schema.*",
]
ignore_missing_imports = true
Expand Down
38 changes: 38 additions & 0 deletions typings/h5py/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import types
from typing import Any, Literal as L
from collections.abc import KeysView, MutableMapping, Generator, Sequence

from numpy.typing import DTypeLike, ArrayLike

class AttributeManager(MutableMapping[str, Any]):
def __setitem__(self, __key: str, __value: ArrayLike) -> None: ...
def __getitem__(self, __key: str) -> Any: ...
def __len__(self) -> int: ...
def __iter__(self) -> Generator[str, None, None]: ...
def __delitem__(self, __key: str) -> None: ...

class Group(MutableMapping[str, Any]):
def __getitem__(self, key: str) -> Any: ...
def __len__(self) -> int: ...
def __iter__(self) -> Generator[str, None, None]: ...
def __setitem__(self, __key: str, __value: Any) -> None: ...
def __delitem__(self, __key: str) -> None: ...
def require_dataset(self, name: str, shape: Sequence[int], dtype: DTypeLike, exact: bool = ..., **kwds: Any) -> Any: ...
def keys(self) -> KeysView[str]: ...
def move(self, source: str, dest: str) -> None: ...
@property
def attrs(self) -> AttributeManager: ...

class File(Group):
def __init__(
self,
name,
mode: L["r", "r+", "w", "w-", "x", "a"] = ...,
) -> None: ...
def __enter__(self) -> File: ...
def __exit__(
self,
__exc_type: type[BaseException] | None,
__exc_val: BaseException | None,
__exc_tb: types.TracebackType | None,
) -> None: ...

0 comments on commit c7a3190

Please sign in to comment.