-
Notifications
You must be signed in to change notification settings - Fork 300
Paint it black again #3518
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
Paint it black again #3518
Conversation
.flake8
Outdated
| # | ||
| .eggs, | ||
| build | ||
| compiled_krb |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should build and compiled_krb have commas after them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stephenworsley Nice, spot 👀
d215a2c to
366753a
Compare
| delta_start = 24 | ||
| delta_mid = 36 | ||
| delta_end = 369 * 24 | ||
| ref_offset = 10 * 24 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These could be made comments.
|
|
||
| patch = mock.patch("netCDF4.Dataset") | ||
| mock_netcdf_dataset = patch.start() | ||
| patch.start() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps set to _.
|
|
||
| Iris uses `black <https://black.readthedocs.io/en/stable/>`_ formatting and `flake8 <https://flake8.pycqa.org/en/stable/>`_ | ||
| linting to enforce a consistent code format throughout the project. ``black`` and ``flake8`` can easily be installed | ||
| into your development environment with ``pip``:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be worthwhile mentioning that this is also possible (and equivalent) with conda.
| $ black . | ||
| $ flake8 . | ||
|
|
||
| Alternatively, we recommend using `pre-commit <https://pre-commit.com/>`_ to automatically run ``black`` and ``flake8`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be worth bringing up that there is good information on IDE integration in the black documentation (and probably also the flake8 documentation, though I haven't looked so much at that myself).
| Alternatively, ``black`` and ``flake8`` may be installed using ``conda`` instead. Note that, ``black`` also offers | ||
| `editor integration <https://black.readthedocs.io/en/stable/editor_integration.html#editor-integration>`_. | ||
|
|
||
| As a developer workflow, we instead recommend using `pre-commit <https://pre-commit.com/>`_ to automatically run ``black`` and ``flake8`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"As a developer workflow," reads a bit clunkily. It almosts sounds as if you are a developer workflow offering a recomendation (consider how the structure of the sentence would change if it started with "as a developer,").
| $ flake8 . | ||
|
|
||
| Alternatively, we recommend using `pre-commit <https://pre-commit.com/>`_ to automatically run ``black`` and ``flake8`` | ||
| Alternatively, ``black`` and ``flake8`` may be installed using ``conda`` instead. Note that, ``black`` also offers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having these two sentances on the same line seems to suggest they are talking about related ideas. To me, it seems as though editor integration is more closely related to the idea of workflows below.
stephenworsley
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good now.
This PR enables black, the opinionated, uncompromising code formatter.
It's a good thing, and I've bought into the hype. Needless to say, so have many other leading scientific python packages, such as dask, xarray, and pandas. If you need more convincing,
... and it even has editor and IDE integration support 😀
This PR also incorporates support for pre-commit git hooks, which when enabled will allow the developer to ensure that all
iriscode in the repository isblackcompliant, by automatically executingblackwhenever a developergit commitcommand is performed. Note that, thepre-commithooks run only against the code changed/new to the PR, and not over the wholeirisrepository - so it's not an expensive act.In addition to enabling the
blackpre-commitgit hook, other hooks I've deemed useful have also been enabled. For a list of supported hooks, see here.Note that,
blackis also now part of thetravis-ciworkflow, to ensure that developers are actually committingblackcompliant code as part of their PR.Also, for the first time ever, this PR make the entire code base
flake8compliant (with# noqaexceptions).Still to do...
blackformatdocs.blackformattests.stickler-ciatblackv18.9b0 conflicts withv19.10b0.stickler-civersion is too old 😞flake8files toignoreforstickler-ci, to temporarily appease it.decide whether to disable.stickler-ciflake8pre-commit hook along withstickler-ciflake8👍flake8inpre-commit(temporary).flake8compliant..flake8files that we explicitlyexclude.flake8inpre-commit.iris.tests.test_coding_standards.TestCodeFormatandiris.tests.test_coding_standards.StandardReportWithExclusions.pp_load_rulesunit test.github/CONTRIBUTING.mdand/or developer notes to provide relevantpre-commitconfiguration details.blackbadge