mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 00:04:42 +04:00
forbid overriding entry for meta hooks
This commit is contained in:
parent
16f68254a8
commit
d3b4f737b9
2 changed files with 16 additions and 0 deletions
|
|
@ -251,12 +251,21 @@ _meta = (
|
|||
),
|
||||
)
|
||||
|
||||
|
||||
class NotAllowed(cfgv.OptionalNoDefault):
|
||||
def check(self, dct: Dict[str, Any]) -> None:
|
||||
if self.key in dct:
|
||||
raise cfgv.ValidationError(f'{self.key!r} cannot be overridden')
|
||||
|
||||
|
||||
META_HOOK_DICT = cfgv.Map(
|
||||
'Hook', 'id',
|
||||
cfgv.Required('id', cfgv.check_string),
|
||||
cfgv.Required('id', cfgv.check_one_of(tuple(k for k, _ in _meta))),
|
||||
# language must be system
|
||||
cfgv.Optional('language', cfgv.check_one_of({'system'}), 'system'),
|
||||
# entry cannot be overridden
|
||||
NotAllowed('entry', cfgv.check_any),
|
||||
*(
|
||||
# default to the hook definition for the meta hooks
|
||||
cfgv.ConditionalOptional(key, cfgv.check_any, value, 'id', hook_id)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue