gaogaotiantian / objprint

A library that can print Python objects in human readable format
Apache License 2.0
519 stars 43 forks source link

`arg_name=True` not usable in Jupyter & IPython #103

Open auderson opened 5 months ago

auderson commented 5 months ago
from objprint import op

def func():
    return 1

cc = op(func(), arg_name=True)

image

maybe it's because here: https://github.com/gaogaotiantian/objprint/blob/7920c8601e86e97fe05a807d820121bac00471b7/src/objprint/frame_analyzer.py#L55-L58

module is None for Jupyter & IPython, but they have file: jupyter: image

ipython: image

and source can be retrieved with: image

Change to source = inspect.getsource(frame) will work: image

gaogaotiantian commented 3 months ago

Hmm, okay. I'll admit that I don't use Jupyter so it's never my first priority. I'll take a look at this and see if can be gracefully fixed.