How to use the jsonargparse.ActionJsonSchema._extend_jsonvalidator_with_default function in jsonargparse

To help you get started, we’ve selected a few jsonargparse examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github omni-us / jsonargparse / View on Github external
if 'ext_vars' in kwargs or 'schema' in kwargs:
            _check_unknown_kwargs(kwargs, {'schema', 'ext_vars'})
            if 'ext_vars' in kwargs and not isinstance(kwargs['ext_vars'], (str, type(None))):
                raise ValueError('ext_vars has to be either None or a string.')
            self._ext_vars = kwargs['ext_vars'] if 'ext_vars' in kwargs else None
            schema = kwargs['schema'] if 'schema' in kwargs else None
            if schema is not None:
                if isinstance(schema, str):
                        schema = yaml.safe_load(schema)
                    except Exception as ex:
                        raise type(ex)('Problems parsing schema :: '+str(ex))
                self._validator = ActionJsonSchema._extend_jsonvalidator_with_default(jsonvalidator)(schema)
                self._validator = None
        elif '_ext_vars' not in kwargs or '_validator' not in kwargs:
            raise ValueError('Expected ext_vars and/or schema keyword arguments.')
            self._ext_vars = kwargs.pop('_ext_vars')
            self._validator = kwargs.pop('_validator')
            kwargs['type'] = str