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

lineWrapWidth not observed properly #60

Open
salabim opened this issue Mar 6, 2021 · 3 comments
Open

lineWrapWidth not observed properly #60

salabim opened this issue Mar 6, 2021 · 3 comments

Comments

@salabim
Copy link

salabim commented Mar 6, 2021

The following code:

from icecream import ic

ic.lineWrapWidth = 100

b = 10 * ['123456']
ic(b)

prints

ic| b: ['123456',
        '123456',
        '123456',
        '123456',
        '123456',
        '123456',
        '123456',
        '123456',
        '123456',
        '123456']

, whereas it all fits on one line, like:

ic| b: ['123456', '123456', '123456', '123456', '123456', '123456', '123456', '123456', '123456', '123456']

The reason for this seems to be that pformat uses a wdth of 80 by default and IceCream doesn't communicate the (reduced) line width to pformat.

@salabim salabim changed the title lineWrapWidth nor obeserved properly lineWrapWidth not observed properly Mar 6, 2021
@gruns
Copy link
Owner

gruns commented Mar 7, 2021

great find!

i dont have time to fix this right now. do you have time to dig in and resolve this with a PR?

@salabim
Copy link
Author

salabim commented Mar 7, 2021

No, I don't have time to resolve this.
However, if someone might want to implement this, he/she could possibly try and backport it from ycecream.

@Gleiphnir
Copy link

Temporary fix to this is to override the default pformat and the lineWrapWidth. Overriding only one, will result in the other taking over, as mentioned elsewhere, since the class does not sync update the two widths. Using this approach I've been able to maintain clean output logs.

preferredWidth = 1000
pp = pprint.PrettyPrinter(width=preferredWidth)
ic.configureOutput(argToStringFunction=pp.pformat)
ic.lineWrapWidth = preferredWidth

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

3 participants