Please consider adding PyPy Trove classifiers, because apparently black works fine! At least on the recent PyPy (I tested PyPy3.6 v7.0 on macOS). I used version 18.9b0 of black. See https://pypy.org/download.html
We should also add validation that this works as part of our CI pipeline.
Happy to review a pull request :)
I was going to give this a shot but it seems travis does not yet have pypy 3.6 available.
Azure Pipelines are planning on adding PyPy: https://github.com/Microsoft/azure-pipelines-tasks/issues/8514.
(See https://github.com/ambv/black/pull/731 for adding Azure Pipelines with CPython to this repo.)
I was actually targeting my PyPy sprint contributions in Dusseldorf with this in mind so I'm happy it works for you :)
To be fully frank, not everything works on PyPy yet, the asyncio parts are failing in particular.
Just as an FYI: I tried configuring this on Travis (see https://github.com/alexchamberlain/black/blob/pypy3/.travis.yml#L36). typed-ast and aiohttp appear to be incompatible with pypy3 if I've configured it correctly.
if you drop pip install -e '.[d]' it will no longer pull in aiohttp (but blackd will not be tested). typed-ast is going away with python 3.8, so we could in theory strip away that dependency from that version on
An update with pypy3.6 v7.2.0:
aiohttp can be installed without any problem.
black==19.3b0 works fine
black==19.10b0 can't be installed because of the typed-ast dependency
typed-ast won't be compatible with PyPy for awhile (https://github.com/python/typed_ast/issues/111).
Wouldn't it be possible to install black without typed-ast on PyPy ?
With typed-ast has a hard dependency, it seems it won't be possible to install black until PyPy reaches 3.8 !
For the record, the PR which introduced the typed-ast dependency: https://github.com/psf/black/pull/840 "Make --safe work for Python2.7 syntax, by using typed_ast".
I want to support PyPy but this is going to be a tough sell.
Well, PyPy3 is now targeting 3.6, working on 3.7. The functionality to parse Python 2 code into an AST on Python 3 was only added in Python 3.8.0. So @zsol is right that we could drop this dependency on Python 3.8 but that doesn't solve the problem for PyPy.
Sadly, we need to be able to convert Python 2 code into AST form to do the sanity checks that Black is doing by default. This found many many bugs and is one of the reasons Black is being trusted by its users even though it's so young of a project.
The reason we chose typed-ast over pure Python parsers on PyPI is that it's written in C and thus pretty fast. This is important because the sanity check is not really core functionality of Black. Sometimes I ponder if --fast might become the default in the future. So, we want --safe not to slow people down beyond what's strictly necessary.
What about installing typed-ast as an optional dependency, e.g. pip install black[typed-ast] or pip install black[fast]? Then PyPy users could use black with native AST.
Please take a look. Works in my case: https://github.com/psf/black/pull/1172
Most helpful comment
What about installing
typed-astas an optional dependency, e.g.pip install black[typed-ast]orpip install black[fast]? ThenPyPyusers could useblackwith native AST.