Skip to content
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

Add pre-commit hook config #2963

Merged
merged 7 commits into from
Sep 12, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
20 changes: 20 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
exclude: \.svg$
- repo: https://github.com/pycqa/flake8
rev: 5.0.4
hooks:
- id: flake8
exclude: seaborn/(cm\.py|external/)
types: [file, python]
- repo: https://github.com/pre-commit/mirrors-mypy
mwaskom marked this conversation as resolved.
Show resolved Hide resolved
rev: v0.971
hooks:
- id: mypy
args: [--follow-imports=skip]
files: seaborn/_(core|marks|stats)/
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,11 @@ To test the code, run `make test` in the source directory. This will exercise bo

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

Code style is enforced with `flake8` using the settings in the [`setup.cfg`](./setup.cfg) file. Run `make lint` to check.
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.

Development
-----------

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

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).

2 changes: 1 addition & 1 deletion ci/deps_pinned.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ scipy~=1.3.0
statsmodels~=0.10.0
# Pillow added in install_requires for later matplotlibs
pillow>=6.2.0
typing_extensions
typing_extensions
1 change: 0 additions & 1 deletion ci/getmsfonts.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | debconf-set-selections
apt-get install msttcorefonts -qq

2 changes: 1 addition & 1 deletion doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Building the docs requires additional dependencies; they can be installed with `

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`.

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`.
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`.

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.

Expand Down
4 changes: 2 additions & 2 deletions doc/_static/copybutton.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
$(document).ready(function() {
/* Add a [>>>] button on the top-right corner of code samples to hide
* the >>> and ... prompts and the output and thus make the code
* copyable.
* copyable.
* Note: This JS snippet was taken from the official python.org
* documentation site.*/
var div = $('.highlight-python .highlight,' +
'.highlight-python3 .highlight,' +
'.highlight-python3 .highlight,' +
'.highlight-pycon .highlight')
var pre = div.find('pre');

Expand Down
1 change: 0 additions & 1 deletion doc/_templates/autosummary/base.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
.. currentmodule:: {{ module }}

.. auto{{ objtype }}:: {{ objname }}

1 change: 0 additions & 1 deletion doc/_templates/autosummary/object.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
.. currentmodule:: {{ module }}

.. autoclass:: {{ objname }}

6 changes: 3 additions & 3 deletions doc/citing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ Tall logo
~~~~~~~~~

.. image:: _static/logo-tall-lightbg.svg
:width: 150px
:width: 150px

Logo mark
~~~~~~~~~

.. image:: _static/logo-mark-lightbg.svg
:width: 150px
:width: 150px

Credit to `Matthias Bussonnier <https://github.com/Carreau>`_ for the initial design
and implementation of the logo.
and implementation of the logo.
6 changes: 3 additions & 3 deletions doc/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ The default "inline" backend (defined by `IPython <https://github.com/ipython/ma
You can increase the DPI by resetting the rc parameters through the matplotlib API, using

::

plt.rcParams.update({"figure.dpi": 96})

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

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::

%config InlineBackend.figure_format = "svg"

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.

Tricky concepts
Expand Down
1 change: 0 additions & 1 deletion doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,3 @@ seaborn: statistical data visualization
* Multi-plot grids: :ref:`API <grid_api>` | :doc:`Tutorial <tutorial/axis_grids>`
* Figure theming: :ref:`API <style_api>` | :doc:`Tutorial <tutorial/aesthetics>`
* Color palettes: :ref:`API <palette_api>` | :doc:`Tutorial <tutorial/color_palettes>`

2 changes: 1 addition & 1 deletion doc/tutorial.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
- title: Figure aesthetics
pages:
- aesthetics
- color_palettes
- color_palettes
4 changes: 2 additions & 2 deletions doc/whatsnew/v0.11.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ The axes-level :func:`histplot` function draws univariate or bivariate histogram
- normalization to show density, probability, or frequency statistics
- flexible parameterization of bin size, including proper bins for discrete variables
- adding a KDE fit to show a smoothed distribution over all bin statistics
- experimental support for histograms over categorical and datetime variables.
- experimental support for histograms over categorical and datetime variables.

The axes-level :func:`ecdfplot` function draws univariate empirical cumulative distribution functions, using a similar interface.

Expand Down Expand Up @@ -133,7 +133,7 @@ Relational plots

- |Defaults| Changed how :func:`scatterplot` sets the default linewidth for the edges of the scatter points. New behavior is to scale with the point sizes themselves (on a plot-wise, not point-wise basis). This change also slightly reduces the default width when point sizes are not varied. Set ``linewidth=0.75`` to reproduce the previous behavior. (:pr:`2708`).

- |Enhancement| Improved support for datetime variables in :func:`scatterplot` and :func:`lineplot` (:pr:`2138`).
- |Enhancement| Improved support for datetime variables in :func:`scatterplot` and :func:`lineplot` (:pr:`2138`).

- |Fix| Fixed a bug where :func:`lineplot` did not pass the ``linestyle`` parameter down to matplotlib (:pr:`2095`).

Expand Down
2 changes: 1 addition & 1 deletion doc/whatsnew/v0.11.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ This a bug fix release and is a recommended upgrade for all users on v0.11.0.

- |Fix| Raise a more informative error in :class:`PairGrid`/:func:`pairplot` when no variables can be found to define the rows/columns of the grid (:pr:`2382`).

- |Fix| Raise a more informative error from :func:`clustermap` if row/col color objects have semantic index but data object does not (:pr:`2313`).
- |Fix| Raise a more informative error from :func:`clustermap` if row/col color objects have semantic index but data object does not (:pr:`2313`).
3 changes: 1 addition & 2 deletions doc/whatsnew/v0.2.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ API changes
allows for increased flexibility in specifying the bandwidth and kernel, and
smarter choices for defining the range of the support. Default options should
produce plots that are very close to the old defaults.

- The ``kdeplot()`` function now takes a second positional argument of data for
drawing bivariate densities.

Expand Down Expand Up @@ -150,4 +150,3 @@ Bug fixes

- All axis styling has been moved out of the top-level ``seaborn.set()``
function, so context or color palette can be cleanly changed.

2 changes: 1 addition & 1 deletion doc/whatsnew/v0.7.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This is a major release from 0.6. The main new feature is :func:`swarmplot` whic

- Improve performance for large dendrograms in :func:`clustermap`.

- Added ``font.size`` to the plotting context definition so that the default output from ``plt.text`` will be scaled appropriately.
- Added ``font.size`` to the plotting context definition so that the default output from ``plt.text`` will be scaled appropriately.

- Fixed a bug in :func:`clustermap` when ``fastcluster`` is not installed.

Expand Down
2 changes: 1 addition & 1 deletion licences/NUMPYDOC_LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
POSSIBILITY OF SUCH DAMAGE.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ dev = [
"pytest-xdist",
"flake8",
"mypy",
"pre-commit",
]
docs = [
"numpydoc",
Expand Down
2 changes: 1 addition & 1 deletion seaborn/external/docscrape.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,4 +712,4 @@ def _is_show_member(self, name):
return True # show all class members
if name not in self._cls.__dict__:
return False # class member is inherited, we do not show it
return True
return True
2 changes: 1 addition & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ def test_move_legend_input_checks():

def check_load_dataset(name):
ds = load_dataset(name, cache=False)
assert(isinstance(ds, pd.DataFrame))
assert isinstance(ds, pd.DataFrame)


def check_load_cached_dataset(name):
Expand Down