Skip to content

Commit 15713b3

Browse files
authored
Add pre-commit hook config (#2963)
* Add pre-commit config file. * Tweak config after running on all files. * Add exclude to flake8 config. * Add pre-commit to dev extras in pyproject.toml * Add pre-commit install to README. * Address whitespace and no newlines across repo. * Address flake8 finding in test_utils.py
1 parent 0f5a013 commit 15713b3

File tree

20 files changed

+42
-27
lines changed

20 files changed

+42
-27
lines changed

.pre-commit-config.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.3.0
4+
hooks:
5+
- id: check-yaml
6+
- id: end-of-file-fixer
7+
- id: trailing-whitespace
8+
exclude: \.svg$
9+
- repo: https://github.com/pycqa/flake8
10+
rev: 5.0.4
11+
hooks:
12+
- id: flake8
13+
exclude: seaborn/(cm\.py|external/)
14+
types: [file, python]
15+
- repo: https://github.com/pre-commit/mirrors-mypy
16+
rev: v0.971
17+
hooks:
18+
- id: mypy
19+
args: [--follow-imports=skip]
20+
files: seaborn/_(core|marks|stats)/

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,11 @@ To test the code, run `make test` in the source directory. This will exercise bo
6464

6565
The doctests require a network connection (unless all example datasets are cached), but the unit tests can be run offline with `make unittests`.
6666

67-
Code style is enforced with `flake8` using the settings in the [`setup.cfg`](./setup.cfg) file. Run `make lint` to check.
68-
67+
Code style is enforced with `flake8` using the settings in the [`setup.cfg`](./setup.cfg) file. Run `make lint` to check. Alternately, you can use `pre-commit` to automatically run lint checks on any files you are committing – just run `pre-commit install` to set it up, and then commit as usual going forward.
68+
6969
Development
7070
-----------
7171

7272
Seaborn development takes place on Github: https://github.com/mwaskom/seaborn
7373

7474
Please submit bugs that you encounter to the [issue tracker](https://github.com/mwaskom/seaborn/issues) with a reproducible example demonstrating the problem. Questions about usage are more at home on StackOverflow, where there is a [seaborn tag](https://stackoverflow.com/questions/tagged/seaborn).
75-

ci/deps_pinned.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ scipy~=1.3.0
55
statsmodels~=0.10.0
66
# Pillow added in install_requires for later matplotlibs
77
pillow>=6.2.0
8-
typing_extensions
8+
typing_extensions

ci/getmsfonts.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | debconf-set-selections
22
apt-get install msttcorefonts -qq
3-

doc/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Building the docs requires additional dependencies; they can be installed with `
55

66
The build process involves conversion of Jupyter notebooks to `rst` files. To facilitate this, you may need to set `NB_KERNEL` environment variable to the name of a kernel on your machine (e.g. `export NB_KERNEL="python3"`). To get a list of available Python kernels, run `jupyter kernelspec list`.
77

8-
After you're set up, run `make notebooks html` from the `doc` directory to convert all notebooks, generate all gallery examples, and build the documentation itself. The site will live in `_build/html`.
8+
After you're set up, run `make notebooks html` from the `doc` directory to convert all notebooks, generate all gallery examples, and build the documentation itself. The site will live in `_build/html`.
99

1010
Run `make clean` to delete the built site and all intermediate files. Run `make -C docstrings clean` or `make -C tutorial clean` to remove intermediate files for the API or tutorial components.
1111

doc/_static/copybutton.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
$(document).ready(function() {
33
/* Add a [>>>] button on the top-right corner of code samples to hide
44
* the >>> and ... prompts and the output and thus make the code
5-
* copyable.
5+
* copyable.
66
* Note: This JS snippet was taken from the official python.org
77
* documentation site.*/
88
var div = $('.highlight-python .highlight,' +
9-
'.highlight-python3 .highlight,' +
9+
'.highlight-python3 .highlight,' +
1010
'.highlight-pycon .highlight')
1111
var pre = div.find('pre');
1212

doc/_templates/autosummary/base.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@
33
.. currentmodule:: {{ module }}
44

55
.. auto{{ objtype }}:: {{ objname }}
6-

doc/_templates/autosummary/object.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@
33
.. currentmodule:: {{ module }}
44

55
.. autoclass:: {{ objname }}
6-

doc/citing.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ Tall logo
4545
~~~~~~~~~
4646

4747
.. image:: _static/logo-tall-lightbg.svg
48-
:width: 150px
48+
:width: 150px
4949

5050
Logo mark
5151
~~~~~~~~~
5252

5353
.. image:: _static/logo-mark-lightbg.svg
54-
:width: 150px
54+
:width: 150px
5555

5656
Credit to `Matthias Bussonnier <https://github.com/Carreau>`_ for the initial design
57-
and implementation of the logo.
57+
and implementation of the logo.

doc/faq.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ The default "inline" backend (defined by `IPython <https://github.com/ipython/ma
6868
You can increase the DPI by resetting the rc parameters through the matplotlib API, using
6969

7070
::
71-
71+
7272
plt.rcParams.update({"figure.dpi": 96})
7373

7474
Or do it as you activate the seaborn theme::
@@ -80,9 +80,9 @@ If you have a high pixel-density monitor, you can make your plots sharper using
8080
%config InlineBackend.figure_format = "retina"
8181

8282
This won't change the apparent size of your plots in a Jupyter interface, but they might appear very large in other contexts (i.e. on GitHub). And they will take up 4x the disk space. Alternatively, you can make SVG plots::
83-
83+
8484
%config InlineBackend.figure_format = "svg"
85-
85+
8686
This will configure matplotlib to emit `vector graphics <https://en.wikipedia.org/wiki/Vector_graphics>`_ with "infinite resolution". The downside is that file size will now scale with the number and complexity of the artists in your plot, and in some cases (e.g., a large scatterplot matrix) the load will impact browser responsiveness.
8787

8888
Tricky concepts

0 commit comments

Comments
 (0)