You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Besides we have composition operators (and, or, etc.)
So we could imagine to provide equivalent objects, directly composable with the python operators :
PositiveInt=InstanceOf(int) &GreaterThan(0)
Advantages:
we could compose the type hints automatically (to check if for example pychamr follows the type hints of __and__
compacity and reuse
Companion needs/features:
if we go down that road, we would need an easy way to define a failure raiser. It could be by blending it with the existing compact syntax, for example
IntMultipleOfTwo=InstanceOf(int) & (lambdax: x%2==0, 'x should be a multiple of 2', CustomType)
factories could maybe be defined as classes "à la checktypes" ? As :
classMultipleOf(...):
params='nb',
base_type=Nonechecker=lambdax, nb: x%nb==0help_msg="x should be multiple of {nb}"
Notes:
we should probably not wish these objects to be classes (like in checktypes). That is maybe more elegant conceptualy but would definitely be less efficient in terms of python (metaclasses, overriding instance_check etc.)
The text was updated successfully, but these errors were encountered:
A failure raiser currently consists in
Failure
)Besides we have composition operators (and, or, etc.)
So we could imagine to provide equivalent objects, directly composable with the python operators :
Advantages:
__and__
Companion needs/features:
Notes:
checktypes
). That is maybe more elegant conceptualy but would definitely be less efficient in terms of python (metaclasses, overriding instance_check etc.)The text was updated successfully, but these errors were encountered: