You need to put the dot in the format string instead of using a decimal value in the assignment to precision
.
>>> '{text:{fill}{align}{width}.{precision}}'.format(text = 'abcdef', width=8, fill = '~', align = '^', precision = 4)
'~~abcd~~'
>>> '{num:{fill}{align}{width}.{precision}{type}}'.format(num = 12.34, width=12, fill = '~', align = '^', type = 'f', precision = 4)
'~~12.3400~~~'
Otherwise, without the dot, width
and the string representation of precision
(.4 becomes '0.4') get concatenated as strings and the integer portion of the result is used as the width. So, in one of your examples where width is 8 and precision is .4, the resulting width becomes 80 (from truncating 80.4).