datatyping icon indicating copy to clipboard operation
datatyping copied to clipboard

Implement datatyping.printer with subclassing

Open carlbordum opened this issue 7 years ago • 5 comments

I was super stupid, when I implemented datatyping.printer.py. It should be implemented with subclassing instead of monkey patching (with context managers). This would also make it thread-safe.

Relevant: #2.

carlbordum avatar Oct 01 '18 19:10 carlbordum

Hey! I just started to do some work on this.

One thing I noticed is that _test_printer.py is hidden from the test suite. Does that have an existing test failure that I should try to fix?

dmonego avatar Oct 01 '18 21:10 dmonego

This PR has the change: https://github.com/carlbordum/datatyping/pull/9

dmonego avatar Oct 01 '18 22:10 dmonego

This is super nice!

Does it make sense for datatyping.printer._new_safe_repr to be in the subclass aswell?

I think I disabled the test, because it makes a http request. Maybe once #4 is done, we can have tests for this.

carlbordum avatar Oct 02 '18 15:10 carlbordum

I don't think _new_safe_repr should be in the subclass - I've tried to put the minimum number of overrides in there, and the current way mirrors how pprint._safe_repr works.

dmonego avatar Oct 02 '18 15:10 dmonego

Awesome work!

/merged/

carlbordum avatar Oct 03 '18 16:10 carlbordum