Skip to content
This repository has been archived by the owner on Jul 8, 2021. It is now read-only.

Blackify #14

Merged
merged 19 commits into from
Aug 13, 2020
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
# https://pycodestyle.readthedocs.io/en/latest/intro.html#error-codes

ignore =
# E203: whitespace before ':'
E203,
# E402: module level imports at top of file
E402,
trexfeathers marked this conversation as resolved.
Show resolved Hide resolved
# E501: line too long
E501,
# W503: line break before binary operator
W503,
# W504: line break after binary operator
Expand Down
27 changes: 27 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 'v3.2.0'
hooks:
# Prevent giant files from being committed.
- id: check-added-large-files
# Check for files that contain merge conflict strings.
- id: check-merge-conflict
# Check for debugger imports and py37+ `breakpoint()` calls in python source.
- id: debug-statements
# Don't commit to master branch.
- id: no-commit-to-branch
- repo: https://github.com/psf/black
rev: '19.10b0'
hooks:
- id: black
# Force black to run on whole repo, using settings from pyproject.toml
pass_filenames: false
args: [--config=./pyproject.toml, .]
- repo: https://gitlab.com/pycqa/flake8
rev: '3.8.3'
hooks:
# Run flake8.
- id: flake8
args: [--config=./.flake8]
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ install:
conda install --quiet -n ${ENV_NAME} --file ${CONDA_REQS_FILE};

# Conda-install our own additional dependencies.
- conda install --file conda_requirements.txt
- conda install --file requirements/conda_requirements.txt

# Output environment debug info
- >
Expand Down Expand Up @@ -90,4 +90,8 @@ install:

script:

- >
echo $(black --version);
black --check $(INSTALL_DIR);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have not replicated Iris' line removing .gitignore - testing has shown that Black is successfully skipping .gitignore automatically.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Iris also has the line - export INSTALL_DIR=$(pwd) within the script section rather than the install section. I don't know if this is relevant or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's present here too, but further up - line 10

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current travis run seems to give "No Path provided. Nothing to do 😴" despite passing. I wonder if - export INSTALL_DIR=$(pwd) is only applying to the contex of the install: block of code and should be moved down to below line 91 where the script: section begins.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seemed safer to declare it a second time. As you've alluded to, it seems that environment variables are independent between the code blocks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, "No Python files are present to be formatted. Nothing to do 😴" seems like an improvement at least.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From local testing, I'm expecting:
All done! ✨ 🍰 ✨

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mystery now is why I get 3 passes locally, but on Travis it doesn't like __init__.py...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I can tell, the only thing that needs changing now is a newline at the end of the __init__.py file, and I suppose it's good to know it's picking that up. I'd say this is good to go once that's done.


- pytest -v ./iris_ugrid/tests
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
<p align="center">
<!-- https://shields.io/ is a good source of these -->
<a href="https://github.com/psf/black">
<img src="https://img.shields.io/badge/code%20style-black-000000.svg"
alt="black" /></a>
</p>

# iris-ugrid
Unstructured mesh library for Iris
5 changes: 2 additions & 3 deletions iris_ugrid/tests/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
def test_iris_installation():
# Check that iris cf loader includes 'exclude' functionality.
# Import a ugrid-specific test, that ought to exist on the branch.
from iris.tests.unit.fileformats.cf.test_CFReader \
import Test_exclude_vars
from iris.tests.unit.fileformats.cf.test_CFReader import Test_exclude_vars

assert hasattr(Test_exclude_vars, 'test_exclude_vars')
assert hasattr(Test_exclude_vars, "test_exclude_vars")
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[tool.black]
line-length = 79
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
black=19.10b0
trexfeathers marked this conversation as resolved.
Show resolved Hide resolved
gridded
pytest