comparison mercurial/interfaces/misc.py @ 52894: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
comparison
equal deleted inserted replaced
52893:483b0bb23085 52894:bde94bd8e8a2
5 5
6 import abc 6 import abc
7 7
8 from typing import ( 8 from typing import (
9 Callable, 9 Callable,
10 Iterator,
10 List, 11 List,
11 Protocol, 12 Protocol,
12 ) 13 )
13 14
14 15
22 ... 23 ...
23 24
24 @abc.abstractmethod 25 @abc.abstractmethod
25 def __call__(self, *args) -> List: 26 def __call__(self, *args) -> List:
26 ... 27 ...
28
29
30 class IDirs(Protocol):
31 '''a multiset of directory names from a set of file paths'''
32
33 @abc.abstractmethod
34 def addpath(self, path: bytes) -> None:
35 ...
36
37 @abc.abstractmethod
38 def delpath(self, path: bytes) -> None:
39 ...
40
41 @abc.abstractmethod
42 def __iter__(self) -> Iterator[bytes]:
43 ...
44
45 @abc.abstractmethod
46 def __contains__(self, d: bytes) -> bool:
47 ...