-
Notifications
You must be signed in to change notification settings - Fork 281
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
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.
@@ -614,7 +614,7 @@ def setUp(self): | |||
self.data = np.array(1, dtype="int32") | |||
|
|||
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,").
See also:
https://en.wikipedia.org/wiki/Garden-path_sentence
@@ -14,7 +14,10 @@ and then manually run from the root of the Iris repository:: | |||
$ black . | |||
$ 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.
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
iris
code in the repository isblack
compliant, by automatically executingblack
whenever a developergit commit
command is performed. Note that, thepre-commit
hooks run only against the code changed/new to the PR, and not over the wholeiris
repository - so it's not an expensive act.In addition to enabling the
black
pre-commit
git hook, other hooks I've deemed useful have also been enabled. For a list of supported hooks, see here.Note that,
black
is also now part of thetravis-ci
workflow, to ensure that developers are actually committingblack
compliant code as part of their PR.Also, for the first time ever, this PR make the entire code base
flake8
compliant (with# noqa
exceptions).Still to do...
black
formatdocs
.black
formattests
.stickler-ci
atblack
v18.9b0 conflicts withv19.10b0
.stickler-ci
version is too old 😞flake8
files toignore
forstickler-ci
, to temporarily appease it.decide whether to disable.stickler-ci
flake8
pre-commit hook along withstickler-ci
flake8
👍flake8
inpre-commit
(temporary).flake8
compliant..flake8
files that we explicitlyexclude
.flake8
inpre-commit
.iris.tests.test_coding_standards.TestCodeFormat
andiris.tests.test_coding_standards.StandardReportWithExclusions
.pp_load_rules
unit test.github/CONTRIBUTING.md
and/or developer notes to provide relevantpre-commit
configuration details.black
badge