QoL: Applied black to code base.
Black ( https://github.com/psf/black ) is quickly becoming the standard way to format python code, and adopting it means we never have to discuss coding style again.
Using black also means that flake8 warnings become much more relevant - i.e. you only see things like 'unused variable' suggesting bugs, not 'you missed a white space at the end of the line over there'.
I'd like to open the discussion on adopting black-formatting for all plotnine code, and this PR is just the result of running black on the current master (so we can see how much the code base changes).
If this get's positive feedback, I also suppose we should add a pre-commit hook for black and flake8.
Thank you for entertaining this idea.
(It should be noted that black by default formats to 88 characters, and prefixes some ':' with a space that flake8 in the current configuration complains about).
This is the first time I am hearing about "black". It is quite radical, after a quick skim I have seen somethings I like and others I do not.
Yes, no automatic code formatter is perfect - or even matching anyone's taste. But in my experience, it reduces friction by outsourcing the style discussion.
I've rerun it with "--skip-string-normalization", since I believe plotnine uses " for user visible text and ' for internals?
Should reduce the diff quite a bit for now.
Putting aside the other reservations I have for now, I see that black is still in beta. Have any big projects adopted it?
tl;dr: Yes, black is being used by some big projects.
Hey, plotnine is still a 0. release ;)
Libraries.io list's some projects using black, here's an excerpt:
- pandas
- pillow
- tornado
- hypothesis
- pypa/packaging
Github lists 7477 repos / 515 python packages using black), I filtered to those with 300 stars or more:
huge-success/sanic 12673 cs01/gdbgui 6768 Delgan/loguru 4518 tiangolo/fastapi 4027 OpenMined/PySyft 3769 iterative/dvc 3406 simonw/datasette 2794 pypa/sampleproject 2444 nteract/papermill 2361 graphql-python/graphene-django 2289 cornellius-gp/gpytorch 1439 Cog-Creators/Red-DiscordBot 1306 ibis-project/ibis 1254 0xProject/0x-monorepo 1112 PrefectHQ/prefect 1108 Flexget/Flexget 1041 pytorch/botorch 986 pipxproject/pipx 829 peterbe/premailer 820 facebook/Ax 800 chezou/tabula-py 798 aws/sagemaker-python-sdk 744 TDAmeritrade/stumpy 727 itamarst/eliot 604 dask/dask-ml 524 OpenIDC/pyoidc 450 tartiflette/tartiflette 432 HunterMcGushion/hyperparameter_hunter 403 bentoml/BentoML 380 ethereum/lahja 340 huge-success/sanic-openapi 336 Pylons/deform 319 stevearc/pypicloud 302 sicara/tf-explain 301
I also checked some more projects from the top of my head for pre-commit black integration:
- poetry
- pipx
- pytest
- sqlalchemy
- flask
and last but not least, I scanned the top 1000 pypi packages by downloads for their githubs (regexping the pypi json for a single repo / a repo matching the package name on github) and checked for the presence of 'black' in *.md, *.txt, *.pre-commit,pyproject.toml, requirements etc.
Of 670 repos I could clone, 86 had such evidence of black.
I carved and adopted black a 2 months ago! Thank you nonetheless.