Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

float addition with tomlkit.items.Integer raises a NotImplementedType Exception #214

Closed
Poofjunior opened this issue Jul 27, 2022 · 5 comments

Comments

@Poofjunior
Copy link

Poofjunior commented Jul 27, 2022

Title says it all. Adding a tomlkit.items.Integer with a float will raise a NotImplementedType exception.

Here's the breaking code:

content = '[table]\nmy_int = 2048'
doc  = parse(content)

doc['table']['my_int'] + 5.0

System Info

Python version: 3.8.13
Tomlkit version: 0.11.1
OS: Windows 10

Other stuff

Some quick googling looks like the same issue shows up in another project here.

@SamirPS
Copy link
Contributor

SamirPS commented Jul 27, 2022

Do you have the logs of the error ?

@Poofjunior
Copy link
Author

I do! Here's the stack trace:

Traceback (most recent call last):
  File "C:\Users\joshua.vasquez\.conda\envs\spim\lib\code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
  File "C:\Users\joshua.vasquez\.conda\envs\spim\lib\site-packages\tomlkit\items.py", line 635, in __add__
    return self._new(result)
  File "C:\Users\joshua.vasquez\.conda\envs\spim\lib\site-packages\tomlkit\items.py", line 665, in _new
    return Integer(result, self._trivia, raw)
  File "C:\Users\joshua.vasquez\.conda\envs\spim\lib\site-packages\tomlkit\items.py", line 606, in __new__
    return super().__new__(cls, value)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NotImplementedType'

@SamirPS
Copy link
Contributor

SamirPS commented Jul 28, 2022

I didn't check the code of tomlkit but if you convert the doc['table']['my_int'] to int it's works ?

@SamirPS
Copy link
Contributor

SamirPS commented Jul 28, 2022

i thinks it's line 640 on items.py : result = super().add(other)

@SamirPS
Copy link
Contributor

SamirPS commented Jul 28, 2022

if you do : doc['table']['my_int'] + 5 it's work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants