예제 #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`.',
        )
예제 #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,
            ), )
예제 #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)
예제 #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))}', )
예제 #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), )
예제 #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?', )
예제 #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')
예제 #9
0
def _check_non_empty_string(val: str) -> None:
    if not val:
        raise cfgv.ValidationError('string cannot be empty')