Example #1
0
def check_min_version(version: str) -> None:
    if parse_version(version) > parse_version(C.VERSION):
        raise cfgv.ValidationError(
            f'pre-commit version {version} is required but version '
            f'{C.VERSION} is installed.  '
            f'Perhaps run `pip install --upgrade pre-commit`.',
        )
Example #2
0
def check_min_version(version):
    if parse_version(version) > parse_version(C.VERSION):
        raise cfgv.ValidationError(
            'pre-commit version {} is required but version {} is installed.  '
            'Perhaps run `pip install --upgrade pre-commit`.'.format(
                version,
                C.VERSION,
            ), )
Example #3
0
 def check(self, dct):
     if dct.get('repo') in {LOCAL, META}:
         self._cond('rev').check(dct)
         self._cond('sha').check(dct)
     elif 'sha' in dct and 'rev' in dct:
         raise cfgv.ValidationError('Cannot specify both sha and rev')
     elif 'sha' in dct:
         self._cond('sha').check(dct)
     else:
         self._cond('rev').check(dct)
 def check(self, dct: Dict[str, Any]) -> None:
     if dct.get("repo") in {LOCAL, META}:
         self._cond("rev").check(dct)
         self._cond("sha").check(dct)
     elif "sha" in dct and "rev" in dct:
         raise cfgv.ValidationError("Cannot specify both sha and rev")
     elif "sha" in dct:
         self._cond("sha").check(dct)
     else:
         self._cond("rev").check(dct)
Example #5
0
 def check(self, dct: dict[str, Any]) -> None:
     all_ids = {
         hook['id']
         for repo in dct['repos'] for hook in repo['hooks']
     }
     unexpected_skip = set(dct.get('ci', {}).get('skip', ())) - all_ids
     if unexpected_skip:
         with cfgv.validate_context('At key: ci'):
             with cfgv.validate_context('At key: skip'):
                 raise cfgv.ValidationError(
                     f'unexpected hook ids: '
                     f'{", ".join(sorted(unexpected_skip))}', )
Example #6
0
def check_type_tag(tag):
    if tag not in ALL_TAGS:
        raise cfgv.ValidationError(
            'Type tag {!r} is not recognized.  '
            'Try upgrading identify and pre-commit?'.format(tag), )
Example #7
0
def check_type_tag(tag: str) -> None:
    if tag not in ALL_TAGS:
        raise cfgv.ValidationError(
            f'Type tag {tag!r} is not recognized.  '
            f'Try upgrading identify and pre-commit?', )
Example #8
0
 def check(self, dct: dict[str, Any]) -> None:
     if self.key in dct:
         raise cfgv.ValidationError(f'{self.key!r} cannot be overridden')
Example #9
0
def _check_non_empty_string(val: str) -> None:
    if not val:
        raise cfgv.ValidationError('string cannot be empty')