Print the value without the argument when accessing/analysing source code fails
- Dominant language
- Python
- Stars
- 10.1k
- Forks
- 231
- PR merge metrics
- No merged PRs in 30d
Description
When ic() doesn't work it just says:
> ic| Error: 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?
To make ic() usable in cases where the same code works under some conditions but not others (e.g. in https://github.com/gruns/icecream/issues/95#issuecomment-874344435 where it doesn't work with pdb but works otherwise), I think it should:
1. Only show the message once, perhaps as a python warning.
2. Always print out the value even without the argument, similar to `snoop.pp`, e.g:
```python
import snoop
exec("snoop.pp(1+2)")
exec("snoop.pp(3+4, 5+6)")
```
```
00:12:53.21 LOG:
00:12:53.21 .... = 3
00:12:53.21 LOG:
00:12:53.21 .... = 7
00:12:53.21 .... = 11
```
Perhaps it could also automatically act as if includeContext=true in such cases to compensate for the missing argument source.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at the ic() entry point and trace the path that emits the source-code analysis error. Check how values are currently formatted and how warnings or repeated failures are handled. Done means the failure message is shown only once and the evaluated value is still printed when the argument cannot be recovered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100