Skip to content
Open
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
19 changes: 19 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,22 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true

stubtest:
runs-on: ubuntu-latest
strategy:
fail-fast: false

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.x
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -e . mypy
- name: Run stubtest
run: python -m mypy.stubtest dirhash

93 changes: 93 additions & 0 deletions src/dirhash-stubs/__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 src/dirhash-stubs/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