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

Commit

Permalink
Blackify (#14)
Browse files Browse the repository at this point in the history
* Flake8 additions.

* Added py-test black to conda requirements.

* Travis pytest --black.

* README black badge.

* Black config file.

* Appeasing black.

* Added pre-commit.

* Pre commit revision numbers.

* Get up to date pytest-black from pip.

* Corrected pytest requirements.

* Pinned black to 19.10b0 .

* Removed use of pytest-black in favour of native black.

* Corrected Travis black lines.

* Corrected Travis black lines.

* Fresh declaration of INSTALL_DIR in Travis script section.

* Trying explicit directory specification for Travis.

* Exclude installed iris files from black check.

* Blackify __init__.
  • Loading branch information
trexfeathers committed Aug 13, 2020
1 parent 1e2eadb commit 7d812b9
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 5 deletions.
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,
# 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]
5 changes: 4 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 @@ -89,5 +89,8 @@ install:


script:
- >
echo $(black --version);
black --check --exclude "iris/" .;
- 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
2 changes: 1 addition & 1 deletion iris_ugrid/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
# licensing details.
"""All tests for the :mod:`iris-ugrid` package."""

__version__ = '0.1.0regrid1'
__version__ = "0.1.0regrid1"
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
gridded
pytest

0 comments on commit 7d812b9

Please sign in to comment.