cknd / stackprinter

Debugging-friendly exceptions for Python
MIT License
1.28k stars 37 forks source link

Option to prevent line wrap of variable #28

Closed spacemanspiff2007 closed 4 years ago

spacemanspiff2007 commented 4 years ago

Hi, thank you for creating stackprinter! It is really nice.

I have a question: I'd like to prevent the the line wrap of the variables.

e.g.

30      p_mock.assert_called_once = <method 'NonCallableMock.assert_called_once' of <MagicMock i
30                                   d='88760712'> mock.py:808>

to

30      p_mock.assert_called_once = <method 'NonCallableMock.assert_called_once' of <MagicMock id='88760712'> mock.py:808>

would it be possible to add a parameter to stackprinter.format that prevents this?

cknd commented 4 years ago

Hi! That should be possible. The wrapping happens down here in a pretty printer routine that is itself pretty convoluted but does already expose the linewrap argument. So it's just a question of wiring this argument all the way up from all the call sites of format_value to a top level config in format()

I'm pretty short on time currently, so I can't promise this will land quickly, though

spacemanspiff2007 commented 4 years ago

I tried to implement it and it seems to work. Could you check the implementation and see if I missed something?

cknd commented 4 years ago

merged #32

cknd commented 4 years ago

(..and released in https://pypi.org/project/stackprinter/0.2.4 :tada:)