Skip to content

Add stubs for dirhash package #13437

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyrightconfig.stricter.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"stubs/corus",
"stubs/dateparser",
"stubs/defusedxml",
"stubs/dirhash",
"stubs/docker",
"stubs/docutils",
"stubs/Flask-SocketIO",
Expand Down
2 changes: 2 additions & 0 deletions stubs/dirhash/METADATA.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
version = "0.5.*"
upstream_repository = "https://github.com/andhus/dirhash-python"
93 changes: 93 additions & 0 deletions stubs/dirhash/dirhash/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
from _typeshed import Incomplete
from collections.abc import Generator, Iterable
from os import PathLike
from typing import TypeVar
from typing_extensions import TypeAlias

_DirNode: TypeAlias = Incomplete # scantree.DirNode
_RecursionPath: TypeAlias = Incomplete # scantree.RecursionPath
_RP = TypeVar("_RP", bound=_RecursionPath)

__all__ = [
"__version__",
"algorithms_guaranteed",
"algorithms_available",
"dirhash",
"dirhash_impl",
"included_paths",
"Filter",
"get_match_patterns",
"Protocol",
]

__version__: str
algorithms_guaranteed: set[str]
algorithms_available: set[str]

def dirhash(
directory: str | PathLike[str],
algorithm: str,
match: Iterable[str] = ("*",),
ignore: Iterable[str] | None = None,
linked_dirs: bool = True,
linked_files: bool = True,
empty_dirs: bool = False,
entry_properties: Iterable[str] = ("name", "data"),
allow_cyclic_links: bool = False,
chunk_size: int = 1048576,
jobs: int = 1,
) -> str: ...
def dirhash_impl(
directory: str | PathLike[str],
algorithm: str,
filter_: Filter | None = None,
protocol: Protocol | None = None,
chunk_size: int = 1048576,
jobs: int = 1,
) -> str: ...
def included_paths(
directory: str | PathLike[str],
match: Iterable[str] = ("*",),
ignore: Iterable[str] | None = None,
linked_dirs: bool = True,
linked_files: bool = True,
empty_dirs: bool = False,
allow_cyclic_links: bool = False,
) -> list[str]: ...

class Filter:
linked_dirs: bool
linked_files: bool
empty_dirs: bool

def __init__(
self,
match_patterns: Iterable[str] | None = None,
linked_dirs: bool = True,
linked_files: bool = True,
empty_dirs: bool = False,
) -> None: ...
@property
def match_patterns(self) -> tuple[str, ...]: ...
def include(self, recursion_path: _RecursionPath) -> bool: ...
def match_file(self, filepath: str | PathLike[str]) -> bool: ...
def __call__(self, paths: Iterable[_RP]) -> Generator[_RP, None, None]: ...

def get_match_patterns(
match: Iterable[str] | None = None,
ignore: Iterable[str] | None = None,
ignore_extensions: Iterable[str] | None = None,
ignore_hidden: bool = False,
) -> list[str]: ...

class Protocol:
class EntryProperties:
NAME: str
DATA: str
IS_LINK: str
options: set[str]

entry_properties: Iterable[str]
allow_cyclic_links: bool
def __init__(self, entry_properties: Iterable[str] = ("name", "data"), allow_cyclic_links: bool = False) -> None: ...
def get_descriptor(self, dir_node: _DirNode) -> str: ...
5 changes: 5 additions & 0 deletions stubs/dirhash/dirhash/cli.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from collections.abc import Sequence
from typing import Any

def main() -> None: ...
def get_kwargs(args: Sequence[str]) -> dict[str, Any]: ... # value depends on the key