Mercurial > public > mercurial-scm > hg-stable
diff mercurial/interfaces/misc.py @ 52906:bde94bd8e8a2
typing: use a protocol to annotate `pathutil.dirs` in repository.py
That is one external import for the repository interface module. One more to go.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sat, 08 Feb 2025 18:15:18 +0100 |
parents | 483b0bb23085 |
children | ba343f763595 |
line wrap: on
line diff
--- a/mercurial/interfaces/misc.py Sat Feb 08 18:12:29 2025 +0100 +++ b/mercurial/interfaces/misc.py Sat Feb 08 18:15:18 2025 +0100 @@ -7,6 +7,7 @@ from typing import ( Callable, + Iterator, List, Protocol, ) @@ -24,3 +25,23 @@ @abc.abstractmethod def __call__(self, *args) -> List: ... + + +class IDirs(Protocol): + '''a multiset of directory names from a set of file paths''' + + @abc.abstractmethod + def addpath(self, path: bytes) -> None: + ... + + @abc.abstractmethod + def delpath(self, path: bytes) -> None: + ... + + @abc.abstractmethod + def __iter__(self) -> Iterator[bytes]: + ... + + @abc.abstractmethod + def __contains__(self, d: bytes) -> bool: + ...