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 subtraction with tomlkit.items.Integer raises a NotImplementedType exception #270

Closed
zerocewl opened this issue Feb 6, 2023 · 0 comments · Fixed by #277
Closed

Comments

@zerocewl
Copy link

zerocewl commented Feb 6, 2023

Subtraction with an tomlkit.items.Integer and a basic python float leads to a NotImplementedType error.

The issue seems to be the same category like the addition issue #214 (with the same solution?).

stack trace:

>>> doc['table']['my_int'] - 5.0
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/robot/Library/Python/3.10/lib/python/site-packages/tomlkit/items.py", line 657, in __sub__
    return self._new(result)
  File "/Users/robot/Library/Python/3.10/lib/python/site-packages/tomlkit/items.py", line 673, in _new
    return Integer(result, self._trivia, raw)
  File "/Users/robot/Library/Python/3.10/lib/python/site-packages/tomlkit/items.py", line 617, in __new__
    return super().__new__(cls, value)
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NotImplementedType'

minimal code which reproduces the error:

import tomlkit
content = '[table]\nmy_int = 2048'
doc = tomlkit.parse(content)
doc['table']['my_int'] - 5.0

used tomlkit version: 0.11.6

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