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

Literal __neg__ is missing support for decimals #2962

Open
WhiteGobo opened this issue Oct 30, 2024 · 0 comments
Open

Literal __neg__ is missing support for decimals #2962

WhiteGobo opened this issue Oct 30, 2024 · 0 comments

Comments

@WhiteGobo
Copy link
Contributor

Using __neg__ on Literals with XSD.decimal throws a TypeError
Any reason not to use duck typing instead of typechecking?

rdflib/rdflib/term.py

Lines 1011 to 1014 in d119ebe

if isinstance(self.value, (int, long_type, float)):
return Literal(self.value.__neg__())
else:
raise TypeError(f"Not a number; {self!r}")

from rdflib import *
Literal("2.4", datatype=XSD.decimal).__neg__()
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

1 participant