valasp.domain package¶
Submodules¶
valasp.domain.names module¶
This module defines domain primitives for class names and predicate names.
-
class
valasp.domain.names.
AttributeName
(value: str)[source]¶ Bases:
valasp.domain.names.PredicateName
A domain primitive for names of attributes.
valasp.domain.primitive_types module¶
The enum Fun
and the primitive types are defined in this module.
The primitive types are markers to be used in annotations. They cannot be instantiated, and offer a very limited set of utility function.
-
class
valasp.domain.primitive_types.
Alpha
[source]¶ Bases:
valasp.domain.primitive_types.Type
Primitive type representing named constants.
This class cannot be instantiated.
-
class
valasp.domain.primitive_types.
Any
[source]¶ Bases:
valasp.domain.primitive_types.Type
Primitive type representing wildcards.
This class cannot be instantiated.
-
class
valasp.domain.primitive_types.
Fun
(value)[source]¶ Bases:
enum.Enum
Modalities for the
validate()
decorator.FORWARD_IMPLICIT means FORWARD for symbols of arity 1, and IMPLICIT otherwise.
FORWARD can be used with symbols of arity 1 and essentially means to leave the init argument as it is.
IMPLICIT must be used if the init argument is expected to be a function with the same name of the symbol. The arguments of the function are unpacked.
TUPLE is like IMPLICIT, but the function is expected to have emtpy name.
-
FORWARD
= 1¶
-
FORWARD_IMPLICIT
= 0¶
-
IMPLICIT
= 2¶
-
TUPLE
= 3¶
-
class
valasp.domain.primitive_types.
Integer
[source]¶ Bases:
valasp.domain.primitive_types.Type
Primitive type representing integers.
This class cannot be instantiated.
-
classmethod
init_code
(arg: str) → List[str][source]¶ Return code to validate the type of the given argument name.
Subclasses are expected to call this method in their init_code() method.
- Parameters
arg – the name of the argument
- Returns
validation code
-
classmethod
max
() → int[source]¶ Return the greatest integer for the ASP system.
- Returns
the greatest integer
-
classmethod
-
class
valasp.domain.primitive_types.
String
[source]¶ Bases:
valasp.domain.primitive_types.Type
Primitive type representing strings.
This class cannot be instantiated.
-
class
valasp.domain.primitive_types.
Type
[source]¶ Bases:
object
Base class for type annotations.
This class cannot be instantiated, and its subclasses are expected to satisfy this invariant.
-
classmethod
get_primitive
(typ: ClassVar) → valasp.domain.primitive_types.Type[source]¶ Return a subclass of Type associated with typ.
- Parameters
typ – a type for which Type.is_primitive(typ) == True
- Raise
KeyError if Type.is_primitive(typ) != True
- Returns
a subclass of Type associated with typ
-
static
init_code
(arg: str) → List[str][source]¶ Return code to validate the type of the given argument name.
Subclasses are expected to call this method in their init_code() method.
- Parameters
arg – the name of the argument
- Returns
validation code
-
classmethod
is_primitive
(typ: ClassVar) → bool[source]¶ Return true if typ is considered a primitive type.
- Parameters
typ – a type
- Returns
true if typ is a primitive type
-
classmethod
valasp.domain.raisers module¶
Any warning and error specific to ValAsp should be defined here.
The policy of the framework is to rely as much as possible on the usual error classes, like TypeError and ValueError.
-
exception
valasp.domain.raisers.
ValAspWarning
[source]¶ Bases:
UserWarning
Generic warning from the framework.