Add support for ANSI on Windows#31
Conversation
This is a belated replacement for the reverted explosion#24. Improvements this time around: Moved the relevant code into upstream colorama, so it plays nicely with other packages using terminal features on Windows, like tqdm. This also gives us basic ANSI support on any old Windows installs out there that still don't have the native ANSI support. I think they're all EOL already so not a big deal, but it's a free bonus, so why not. Last time, we had to revert due to a bug in handling "fake" consoles like Jupyter notebooks. This time, we're using code that's already been out in the wild for ~1 month with no issues reported, so hopefully there won't be any need for emergency reverts.
|
I'm not immediately sure what the best way is to do it, but it would be nice to have some tests for this including some direct notebook-related tests? |
|
Test failures are a bug in the upstream colorama type stub package; PR to fix it here: python/typeshed#9234 In the mean time I guess I'll use a |
|
@adrianeboyd I added a smoke test for jupyter, making sure we don't crash when importing/using wasabi inside a notebook execution context, like happened before. I don't know how to test it against a real Windows console in CI. But that's really colorama upstream's problem to worry about anyway, I think? |
993b4c2 to
440774b
Compare
|
Also converted to draft for the moment, because the typeshed folks were really quick and already merged the type stubs fix, plus they have automated machinery to do releases every 3 hours. So we should be able to drop the |
440774b to
8d5ae10
Compare
Avoids making mypy complain about missing jupyter stubs
|
Take a look at how this is handled in the |
|
How what's handled in the thinc tests? I just grepped them for |
|
Tests with |
|
Oh I see, using And yeah, I confirmed that nbconvert does use the special |
|
The thinc tests don't have the python 3.6 issue, what's the difference? |
|
I'd rather do this in the test requirements (which I just found on github somewhere and haven't tested) than skip the test: But if just installing |
|
It looks like the thinc tests have a stripped down set of packages and also they're pinned to several-year-old versions: Not sure which part matters, but yeah it looks like we can get the jupyter test working on 3.6. I'll fiddle around and see what works. |
|
Okay, I think this is good to go? |
richardpaulhudson
left a comment
There was a problem hiding this comment.
LGTM! I can also confirm it works on the Windows laptop to which I have access.
This is a belated replacement for the reverted #24.
Improvements this time around:
Moved the relevant code into upstream colorama, so it plays nicely with other packages using terminal features on Windows, like tqdm.
This also gives us basic ANSI support on any old Windows installs out there that still don't have the native ANSI support. I think they're all EOL already so not a big deal, but it's a free bonus, so why not.
Last time, we had to revert due to a bug in handling "fake" consoles like Jupyter notebooks. This time, we're using code that's already been out in the wild for ~1 month with no issues reported, so hopefully there won't be any need for emergency reverts.
CC @richardpaulhudson