transforms
Pad
¶
Type transformation to pad a value to length
with padding
.
Ensures that value will be at least length
long. padding
should be the same type as value, so the concatenation functions properly
Type Constraints¶
- Support
len()
- Support
+
for concatenation (likestr
orlist
)
Example¶
import arc
from arc.transforms import Pad
@arc.command()
def command(val: Annotated[str, Pad(6, 'b')])
arc.print(val)
command()
Source code in arc/types/transforms/size.py
Truncate
¶
Type transformation to truncate a value to length
Type Constraints¶
- Support list-like slice access
Example¶
import arc
from arc.transforms import Truncate
@arc.command()
def command(val: Annotated[str, Truncate(6)])
arc.print(val)
command()
Source code in arc/types/transforms/size.py
Round
¶
Type Tranformation to round given input to ndigits
Type Contraints¶
- Supports
round()
Example¶
import arc
from arc.transforms import Round
@arc.command()
def command(val: Annotated[float, Round(2)])
arc.print(val)
command()