-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Format using black #156
Comments
I've never used jupyterlab, so I don't really understand everything you're suggesting here. Does it work with Pycharm? Are there additional setup/configuration things that would be needed to do it? Can it be applied to notebooks that people PR as well? I think an autoformatter is great in principle, though I'm hesitant to implement anything that will add extra steps for novice python users to make contributions. I have had the experience before of contributing to an open source project and having to figure out how to use their formatting scripts to do so, which I found quite annoying. Especially considering the relatively small size of the Python codebase in this project, I would want to make sure this doesn't introduce any barrier of entry to contributing |
Ah, my bad. Jupyterlab was a bit of red herring, I mentioned it because it's surprising that it works for notebooks because
Yes, though this is maybe something that would be better to do manually. I use https://jupyterlab-code-formatter.readthedocs.io/en/latest/index.html and there's an option to format the entire notebook
I've been there, the flake8 linting errors when contributing to matplotlib can be extremely confusing. This can definitely be implemented in such a way that it doesn't introduce a barrier. Essentially the direction would be:
this can also be set up so that it runs every time you This could also be something that just gets done every now and again as a one-off |
That's honestly the strongest possible argument for it :)
Using You can make the contributing install instructions look something like git clone <your fork>
cd pycro-manager
pip install -e ".[dev]"
pre-commit install and then everything will be set up. |
And you can add an automatic check on to run on PRs using github actions. see here https://github.com/ianhi/mpl-interactions/blob/04eb663503dcd80556c2a5e7ac74348464af2621/.github/workflows/test.yml#L52 |
Sounds great, go for it! |
Figure I'm on a roll of suggesting cosmetic rather than substantive changes so may as well continue.
Problem
As more people contribute to this repo it will become more and more difficult to maintain a consistent code style and keep everything readable.
Proposed Solution
Enforce all code to be autoformatted by https://github.com/psf/black. This is nice because unlike tools like pep8 or flake8 etc it will actually modify the code to conform to the style guide for you.
Additional context
One of the few configurable options is the line length, so this woud not constrain line length.
I got hooked on this when we added it to jupyterlab-git and now I use it in all my personal projects. Here is an example PR of formatting everything + adding a formatting check to tests + adding a precommit git hook to autoformat jupyterlab/jupyterlab-git#763
It also is supported in editors and there is even an extension integrating it into jupyterlab https://jupyterlab-code-formatter.readthedocs.io/en/latest/index.html
The text was updated successfully, but these errors were encountered: