Open lucatrv opened 5 years ago
Although I like this idea, it looks like the black API has changed recently, so this doesn't always work. On my current installation (black 19.3b0), this throws
TypeError: format_str() takes 1 positional argument but 2 were given
while the method signature appears to expect a filemode dataclass object (see https://github.com/psf/black/blob/19.3b0/black.py#L664). It looks like your version would have worked with the previous API from 18.9b0 (see https://github.com/psf/black/blob/18.9b0/black.py#L621-L623). I guess this is what we get for black still being "beta". A small try/except could probably cover both versions?
Thanks for the PR, btw 👍
That's strange, it's working on me with black 19.3b0. I'm on Windows 7, with Miniconda on "conda-forge" channel.
Hmm, curiouser & curiouser. I'm on macOs, using 19.3b0 from PyPi. I'll try to give it a shot on windows at some point. Alternatively, perhaps it would be worth adding python tests for these snippets...
Really great idea!
Now it works with the new Black API.
Thanks for this PR. Is it ready to be merged ?
I think it has been for a while already...
Based on: https://gist.github.com/MarvinT/a072aa992e977496974aaf492287b08c#file-black_code_prettify-json