types.middleware.transformers¶
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.types.middleware import Pad
@arc.command
def command(val: Annotated[str, Pad(6, 'b')])
arc.print(val)
command()
Source code in /home/runner/work/arc/arc/arc/types/middleware/transformers.py
Round
¶
Type Tranformation to round given input to ndigits
Type Contraints¶
- Supports
round()
Example¶
import arc
from arc.types.middleware import Round
@arc.command
def command(val: Annotated[float, Round(2)])
arc.print(val)
command()
Source code in /home/runner/work/arc/arc/arc/types/middleware/transformers.py
Truncate
¶
Type transformation to truncate a value to length
Type Constraints¶
- Support list-like slice access
Example¶
import arc
from arc.types.middleware import Truncate
@arc.command
def command(val: Annotated[str, Truncate(6)])
arc.print(val)
command()