Skip to content

Commit 123c537

Browse files
committed
Move linting to dedicated file, add 'isort' and 'doc8'
1 parent a02f2ef commit 123c537

File tree

5 files changed

+81
-7
lines changed

5 files changed

+81
-7
lines changed

.pre-commit-config.yaml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,36 @@
11
# See: https://pre-commit.com/hooks.html
2+
# Must put flake8 in separate group so 'black' is executed first
23
repos:
34
- repo: https://github.com/pre-commit/pre-commit-hooks
4-
rev: v2.2.3
5+
rev: v3.1.0
56
hooks:
67
- id: no-commit-to-branch
78
- id: double-quote-string-fixer
89
- id: check-docstring-first
910
- id: check-merge-conflict
1011
- id: end-of-file-fixer
1112
- id: trailing-whitespace
13+
14+
# - repo: https://github.com/ambv/black
15+
# rev: 19.10
16+
# hooks:
17+
# - id: black
18+
# args: ['--line-length', '88', '--skip-string-normalization']
19+
20+
- repo: https://github.com/pre-commit/mirrors-isort
21+
rev: v4.3.21
22+
hooks:
23+
- id: isort
24+
args: ['--line-width', '88']
25+
26+
- repo: https://github.com/PyCQA/flake8
27+
rev: 3.8.3
28+
hooks:
1229
- id: flake8
1330
args: ['--max-line-length=88', '--ignore=W503,E402,E741']
31+
32+
- repo: https://github.com/PyCQA/doc8
33+
rev: 0.8.1
34+
hooks:
35+
- id: doc8
36+
args: ['--max-line-length', '88', '--allow-long-titles']

.travis.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# Travis Continuos Integration
22
# Currently only tests notebook files
33
# Based on http://conda.pydata.org/docs/travis.html
4-
# Not sure why pip install . is necessary since conf.py adds it
5-
# to the the path. Maybe nbsphinx executes in separate environment.
64
sudo: false # use container based build
75
language: python
86
notifications:
@@ -30,15 +28,16 @@ before_install:
3028
- conda info -a
3129

3230
install:
33-
- conda env create -n proplot-dev --file docs/environment.yml
31+
- conda env create -n proplot-dev --file ci/environment.yml
3432
- source activate proplot-dev
35-
- pip install flake8
3633
- conda list
3734
- which conda
3835
- which python
36+
- pip install .
37+
- python setup.py install --user
3938

4039
script:
41-
- flake8 proplot docs --max-line-length=88 --ignore=W503,E402,E741
40+
- ci/run-linter.sh
4241
- pushd docs
4342
- make html
4443
- popd

ci/environment.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Hard requirements for running tests
2+
# NOTE: Basemap is broken as of matplotlib >=3.3 so for documentation
3+
# use 3.2.1. Probably lots of basemap holdouts for next ~5 years.
4+
# NOTE: PyQt5 is needed by pyplot, RTD server *happens* to already have it
5+
# but creating local environment will fail.
6+
name: proplot-dev
7+
channels:
8+
- conda-forge
9+
dependencies:
10+
- python>=3.6
11+
- numpy
12+
- xarray
13+
- pandas
14+
- matplotlib==3.2.1
15+
- cartopy
16+
- basemap
17+
- pandoc
18+
- ipykernel
19+
- pip
20+
- pip:
21+
- ..
22+
- flake8
23+
- isort
24+
- doc8
25+
- pytest
26+
- pytest-sugar
27+
- sphinx>=3.0
28+
- sphinx-copybutton
29+
- sphinx_rtd_theme
30+
- jupytext
31+
- nbsphinx
32+
- git+https://github.com/lukelbd/[email protected]
33+
- pyqt5

ci/run-linter.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
set -e
3+
set -eo pipefail
4+
5+
echo 'Code Styling with (flake8, isort)'
6+
7+
source activate proplot-dev
8+
9+
echo '[flake8]'
10+
flake8 proplot docs --max-line-length=88 --ignore=W503,E402,E741
11+
12+
# TODO: Add this
13+
# echo '[black]'
14+
# black --check -S proplot
15+
16+
echo '[isort]'
17+
isort --recursive --check-only --line-width=88 proplot
18+
19+
echo '[doc8]'
20+
doc8 *.rst docs --max-line-length=88

docs/environment.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Hard requirements for notebook examples and documentation build
2-
# Proplot itself just needs matplotlib
32
# NOTE: Basemap is broken as of matplotlib >=3.3 so for documentation
43
# use 3.2.1. Probably lots of basemap holdouts for next ~5 years.
54
# NOTE: PyQt5 is needed by pyplot, RTD server *happens* to already have it

0 commit comments

Comments
 (0)