question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Converters cannot convert datetime.timedelta to float.

See original GitHub issue

hello devs. During a conversation about an issue of graphql-core @jkimbo found a possible error

https://github.com/graphql-python/graphene-django/blob/5051d3bb617ce6977eebc023c958bd10de91fe91/graphene_django/converter.py#L111-L113

raising something like { "message": "float() argument must be a string or a number, not 'datetime.timedelta'" }

you can check https://github.com/graphql-python/graphql-core/issues/150 for more info.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:2
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
zethcommented, Oct 17, 2019

This is a bad bot. This is still an issue.

1reaction
dionyselfcommented, Dec 25, 2017

I managed to get an human readlable for string type by using duration = graphene.String()

https://github.com/dionyself/leaky/blob/71ec608204a3dd66f2fcd25ff36096ba25eb62bc/warehouses/schema/query/asset.py#L8-L13

We probably won’t need and human readable for the Float converter, so using timedelta.total_seconds() is fine… but, i think this works in py3 only

Read more comments on GitHub >

github_iconTop Results From Across the Web

Converting a timedelta to a float - Make More Machines
The problem You need to convert a time difference into a floating point quantity, like 2.5 days. Or you may want to do...
Read more >
Convert timedelta to floating-point - python - Stack Overflow
I got a timedelta object from the subtraction of two datetimes. I need this value as floating point for further calculations.
Read more >
converting timedelta to float | Edureka Community
Use the following piece of code: x1=datetime.timedelta(days=3000, seconds=0, microseconds=0, milliseconds=0, minutes=40, hours=5, weeks=8)
Read more >
how to convert datetime.timedelta to float Code Example
instead, can convert timedelta to float of second time_d_float = time_d.total_seconds()
Read more >
Time series / date functionality — pandas 1.5.2 documentation
Similar to datetime.timedelta from the standard library. ... Rounding during conversion from float to high precision Timestamp is unavoidable.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found