Closed ehudhala closed 1 year ago
I don't like the idea of solving this problem with more configuration. icecream already has many options, I don't the the API should be bloated further. This also isn't very convenient. I think changing the default behaviour would be better. I think:
@alexmojaki Thanks for the suggestions!
Originally I didn't want to change the behavior too much so I left ic printing the warning as the value but I like your suggestion a lot better.
I've updated the PR to issue a warning using the standard python warnings
module.
After the update running the same code snippet and changing the source file during the sleep:
# foobar.py
from icecream import ic
from time import sleep
a, b = 1, 2
sleep(10)
ic(a, b)
Will result in the following output:
./foobar.py:5: RuntimeWarning: Failed to access the underlying source code for analysis. Was ic() invoked in a REPL (e.g. from the command line), a frozen application (e.g. packaged with PyInstaller), or did the underlying source code change during execution?
ic| 1, 2
Code and behaviour seems good to me, thanks! @gruns any objections to this change?
@ehudhala
@alexmojaki
You'll have to release though
I often run into this problem with long-running processes and was considering addressing it myself, then came across this awesome PR! Thanks for your hard work!
Hey :) Pinging back here since we didn't end up releasing a new version with this update. I've been using my local clone of icecream but we should probably release this as a public build. @gruns is it possible for me to help somehow with the release process?
A common usage scenario of icecream is debugging long running processes. As part of the debug process a common scenario is that the underlying source code is updated with new insights. The current behavior causes all the scheduled prints using
ic()
to fail and only show the following message:This fix understands that the user probably still wants to see their printed debug values even if icecream can't introspect the arguments themselves. After this PR is merged if we run:
And change the underlying source code during the sleep period, ic will still print the values:
Since the default error message is really long and informative we want to allow users to configure the error message so that on the common scenario of a known source change when a user prints a value they can configure a short message that looks something like: