mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Keep additional_dependencies in the order in which they are specified
This commit is contained in:
parent
7f18b03201
commit
397efa8080
2 changed files with 28 additions and 3 deletions
|
|
@ -64,7 +64,7 @@ class Repository(object):
|
|||
|
||||
@cached_property
|
||||
def additional_dependencies(self):
|
||||
dep_dict = defaultdict(lambda: defaultdict(set))
|
||||
dep_dict = defaultdict(lambda: defaultdict(_UniqueList))
|
||||
for _, hook in self.hooks:
|
||||
dep_dict[hook['language']][hook['language_version']].update(
|
||||
hook.get('additional_dependencies', []),
|
||||
|
|
@ -222,3 +222,14 @@ class LocalRepository(Repository):
|
|||
@cached_property
|
||||
def manifest(self):
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
class _UniqueList(list):
|
||||
def __init__(self):
|
||||
self._set = set()
|
||||
|
||||
def update(self, obj):
|
||||
for item in obj:
|
||||
if item not in self._set:
|
||||
self._set.add(item)
|
||||
self.append(item)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue