Skip to content

Object of type 'Float' has no len() #562

Closed

Description

@drewoldag

We recently updated to tomlkit 0.15.0 from 0.14.0 and we have stumbled across an odd bug that can be reproduced with this snippet of code:

import tomlkit
import torch

arr = tomlkit.loads("""
a = [1.0, 2.0, 3.0]
""")

print(arr)
print(type(arr['a']))
print(type(arr['a'][0]))
t = torch.tensor(arr['a'], dtype=torch.float32)

Output with tomlkit==0.15.0

{'a': [1.0, 2.0, 3.0]}
<class 'tomlkit.items.Array'>
<class 'tomlkit.items.Float'>
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
      7 
      8 print(arr)
      9 print(type(arr['a']))
     10 print(type(arr['a'][0]))
---> 11 t = torch.tensor(arr['a'], dtype=torch.float32)

TypeError: object of type 'Float' has no len()

Output with tomlkit==0.14.0

{'a': [1.0, 2.0, 3.0]}
<class 'tomlkit.items.Array'>
<class 'tomlkit.items.Float'>

The expectation is that we should be able to read an array of floats from the .toml file and treat it as we would a python list of floats.

Activity

  1. drewoldag commented on Jul 16, 2026

    @drewoldag
    Author

    I see that the PR for the fix has already been merged - thanks for the quick turn around! Is there an estimated date for when the fix will be included in a versioned release?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions