OpenQuizz
Une application de gestion des contenus pédagogiques
TypeChecker Class Reference
Inheritance diagram for TypeChecker:
Collaboration diagram for TypeChecker:

Public Member Functions

def is_type (self, instance, type)
 
def redefine (self, type, fn)
 
def redefine_many (self, definitions=())
 
def remove (self, *types)
 

Static Public Attributes

 default
 
 converter
 

Detailed Description

A ``type`` property checker.

A `TypeChecker` performs type checking for an `IValidator`. Type
checks to perform are updated using `TypeChecker.redefine` or
`TypeChecker.redefine_many` and removed via `TypeChecker.remove`.
Each of these return a new `TypeChecker` object.

Arguments:

    type_checkers (dict):

        The initial mapping of types to their checking functions.

Member Function Documentation

◆ is_type()

def is_type (   self,
  instance,
  type 
)
Check if the instance is of the appropriate type.

Arguments:

    instance (object):

The instance to check

    type (str):

The name of the type that is expected.

Returns:

    bool: Whether it conformed.


Raises:

    `jsonschema.exceptions.UndefinedTypeCheck`:
if type is unknown to this object.

◆ redefine()

def redefine (   self,
  type,
  fn 
)
Produce a new checker with the given type redefined.

Arguments:

    type (str):

The name of the type to check.

    fn (collections.Callable):

A function taking exactly two parameters - the type
checker calling the function and the instance to check.
The function should return true if instance is of this
type and false otherwise.

Returns:

    A new `TypeChecker` instance.

◆ redefine_many()

def redefine_many (   self,
  definitions = () 
)
Produce a new checker with the given types redefined.

Arguments:

    definitions (dict):

A dictionary mapping types to their checking functions.

Returns:

    A new `TypeChecker` instance.

◆ remove()

def remove (   self,
types 
)
Produce a new checker with the given types forgotten.

Arguments:

    types (~collections.Iterable):

the names of the types to remove.

Returns:

    A new `TypeChecker` instance

Raises:

    `jsonschema.exceptions.UndefinedTypeCheck`:

if any given type is unknown to this object

Field Documentation

◆ converter

converter
static

◆ default

default
static

The documentation for this class was generated from the following file: