Skip to content

Expose IValidator via PEP544 Protocols #548

@corentinghigny

Description

@corentinghigny

I have an issue similar to #239 but somewhat different.
I would like to be able to reach IValidator to use type-hinting in functions.

If I want to create a function where a validator can be passed in parameter, it cannot be type-hinted:

def handle_ndjson(
  path:str, 
  validator:jsonschema.IValidator, 
  valid_object_fn: Callable[[dict], None], 
  invalid_object_fn: Callable[[dict, jsonschema.ValidationException], None]):

fails because jsonschema.IValidator isn't exposed (as explained in #239).
The purpose is not to allow the creation of new validator, but to allow the user to chose between the different draft. Is there a graceful way to do that?

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementSome new desired functionalityHelp WantedAn enhancement or bug for which a pull request is welcomed and which should have a clear definition.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions