carlbordum / datatyping

Pythonic type checking
http://datatyping.readthedocs.io
MIT License
35 stars 4 forks source link

Implement datatyping.printer with subclassing #7

Open carlbordum opened 5 years ago

carlbordum commented 5 years ago

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.

dmonego commented 5 years ago

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 commented 5 years ago

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

carlbordum commented 5 years ago

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.

dmonego commented 5 years ago

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.

carlbordum commented 5 years ago

Awesome work!

/merged/