Mercurial > public > mercurial-scm > hg
comparison mercurial/util.py @ 52892:acaf6bad6b89
typing: adds annotation to util.hooks
This prepare the introduction of a typing.Protocol for it.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sun, 09 Feb 2025 22:45:16 +0100 |
parents | abcfb4ce132e |
children | 483b0bb23085 |
comparison
equal
deleted
inserted
replaced
52891:d5f8a336e2ef | 52892:acaf6bad6b89 |
---|---|
3190 based on the names of their sources.""" | 3190 based on the names of their sources.""" |
3191 | 3191 |
3192 def __init__(self): | 3192 def __init__(self): |
3193 self._hooks = [] | 3193 self._hooks = [] |
3194 | 3194 |
3195 def add(self, source, hook): | 3195 def add(self, source: bytes, hook: Callable) -> None: |
3196 self._hooks.append((source, hook)) | 3196 self._hooks.append((source, hook)) |
3197 | 3197 |
3198 def __call__(self, *args): | 3198 def __call__(self, *args) -> List: |
3199 self._hooks.sort(key=lambda x: x[0]) | 3199 self._hooks.sort(key=lambda x: x[0]) |
3200 results = [] | 3200 results = [] |
3201 for source, hook in self._hooks: | 3201 for source, hook in self._hooks: |
3202 results.append(hook(*args)) | 3202 results.append(hook(*args)) |
3203 return results | 3203 return results |