Skip to content

STY: Apply pre-commit hooks to codebase #22809

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

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# style: end-of-file-fixer pre-commit hook
c1a33a481b9c2df605bcb9bef9c19fe65c3dac21

# style: trailing-whitespace pre-commit hook
213061c0804530d04bbbd5c259f10dc8504e5b2b

# style: check-docstring-first pre-commit hook
046533797725293dfc2a6edb9f536b25f08aa636
Comment on lines +1 to +8
Copy link
Contributor Author

@matthewfeickert matthewfeickert Apr 13, 2022

Choose a reason for hiding this comment

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

After this last rebase:

$ git log --graph --oneline --decorate --all | head -n 7
* 48ade7d904 (HEAD -> mnt/apply-pre-commit-to-all-files, origin/mnt/apply-pre-commit-to-all-files) DOC: Add pre-commit hook run dev instructions
* 4c003775bb DEV: Add .git-blame-ignore-revs to ignore style in blame view
* 0465337977 STY: Apply check-docstring-first pre-commit hook
* 213061c080 STY: Apply trailing-whitespace pre-commit hook
* c1a33a481b STY: Apply end-of-file-fixer pre-commit hook
* 787bdf08e5 MNT: Update pre-commit hooks to latest versions
* 95038d96a4 DEV: Exclude LICENSE files from pre-commit

and

$ git grep "c1a33a481b\|0465337977\|213061c080"
.git-blame-ignore-revs:c1a33a481b9c2df605bcb9bef9c19fe65c3dac21
.git-blame-ignore-revs:213061c0804530d04bbbd5c259f10dc8504e5b2b
.git-blame-ignore-revs:046533797725293dfc2a6edb9f536b25f08aa636

so these are correct. 👍

As a single line checker:

$ git log --oneline | head -n 7 | grep STY | awk '{print $1}' | xargs -I {} git grep {}
.git-blame-ignore-revs:046533797725293dfc2a6edb9f536b25f08aa636
.git-blame-ignore-revs:213061c0804530d04bbbd5c259f10dc8504e5b2b
.git-blame-ignore-revs:c1a33a481b9c2df605bcb9bef9c19fe65c3dac21

8 changes: 4 additions & 4 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ body:
id: summary
attributes:
label: Bug summary
description: Describe the bug in 1-2 short sentences
placeholder:
description: Describe the bug in 1-2 short sentences
placeholder:
value:
validations:
required: true
- type: textarea
id: reproduction
attributes:
label: Code for reproduction
description: If possible, please provide a minimum self-contained example.
description: If possible, please provide a minimum self-contained example.
placeholder: Paste your code here
render: python
validations:
Expand Down Expand Up @@ -59,7 +59,7 @@ body:
required: true
- type: input
id: matplotlib-backend
attributes:
attributes:
label: Matplotlib Backend
description: "From Python prompt: `import matplotlib; print(matplotlib.get_backend())`"
- type: input
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ body:
id: problem
attributes:
label: Problem
description: What is missing, unclear, or wrong in the documentation?
description: What is missing, unclear, or wrong in the documentation?
placeholder: |
* I found [...] to be unclear because [...]
* [...] made me think that [...] when really it should be [...]
Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/maintenance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ body:
id: summary
attributes:
label: Summary
description: Please provide 1-2 short sentences that succinctly describes what could be improved.
description: Please provide 1-2 short sentences that succinctly describes what could be improved.
validations:
required: true
- type: textarea
id: fix
attributes:
label: Proposed fix
description: Please describe how you think this could be improved.
description: Please describe how you think this could be improved.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -305,4 +305,4 @@ jobs:
pinned: false
close-previous: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5 changes: 3 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ ci:
exclude: |
(?x)^(
extern|
LICENSE|
lib/matplotlib/mpl-data|
doc/devel/gitwash|
doc/users/prev|
Expand All @@ -12,7 +13,7 @@ exclude: |
)
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
rev: v4.2.0
hooks:
- id: check-added-large-files
- id: check-docstring-first
Expand All @@ -22,7 +23,7 @@ repos:
- id: trailing-whitespace
exclude_types: [svg]
- repo: https://github.com/pycqa/flake8
rev: 3.9.2
rev: 4.0.1
hooks:
- id: flake8
additional_dependencies: [pydocstyle>5.1.0, flake8-docstrings>1.4.0]
Expand Down
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ representative at an online or offline event.
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
matplotlib@numfocus.org (monitored by Thomas Caswell (\@tacaswell) and Hannah
Aizenman (\@story645)) or a report can be made using the [NumFOCUS Code of Conduct report form][numfocus form].
Aizenman (\@story645)) or a report can be made using the [NumFOCUS Code of Conduct report form][numfocus form].
If community leaders cannot come to a resolution about enforcement, reports will be escalated to the NumFocus Code of Conduct committee (conduct@numfocus.org).
All complaints will be reviewed and investigated promptly and fairly.

Expand Down
1 change: 0 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,3 @@ For more information, please visit `the informational page
<https://sustainable-open-science-and-software.github.io/>`__ or download the
`participant information sheet
<https://sustainable-open-science-and-software.github.io/assets/PIS_sustainable_software.pdf>`__.

6 changes: 3 additions & 3 deletions doc/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ This is the top level build directory for the Matplotlib
documentation. All of the documentation is written using sphinx, a
python documentation system built on top of ReST. This directory contains

* users - the user documentation, e.g., installation, plotting tutorials,
* users - the user documentation, e.g., installation, plotting tutorials,
configuration tips, faq, explaations, etc.

* devel - documentation for Matplotlib developers

* api - placeholders to automatically generate the api documentation

* tutorials, plot_types, and gallery - automatically
* tutorials, plot_types, and gallery - automatically
generated by sphinx-gallery from ``../tutorials``, ``../plot_types``, and
``../examples`` respectively (these are only present if docs have been
built locally).
built locally).

* thirdpartypackages - redirect to <https://matplotlib.org/mpl-third-party/>

Expand Down
1 change: 0 additions & 1 deletion doc/_static/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ contour_frontpage.png
histogram_frontpage.png
membrane_frontpage.png
surface3d_frontpage.png

2 changes: 1 addition & 1 deletion doc/_static/switcher.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
"name": "2.2",
"version": "2.2.4"
},
]
]
6 changes: 3 additions & 3 deletions doc/_templates/automodule.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
treat this separately (sphinx-doc/sphinx/issues/4874)
.. automodule:: {{ fullname }}
:members:

{% else %}

.. automodule:: {{ fullname }}
Expand All @@ -18,7 +18,7 @@
Classes
-------

.. autosummary::
.. autosummary::
:template: autosummary.rst
:toctree:
{% for item in classes %}{% if item not in ['zip', 'map', 'reduce'] %}
Expand All @@ -32,7 +32,7 @@ Classes
Functions
---------

.. autosummary::
.. autosummary::
:template: autosummary.rst
:toctree:

Expand Down
1 change: 0 additions & 1 deletion doc/api/_enums_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@
.. autoclass:: CapStyle
:members: demo
:exclude-members: butt, round, projecting, input_description

1 change: 0 additions & 1 deletion doc/api/lines_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@ Functions
:template: autosummary.rst

segment_hits

2 changes: 1 addition & 1 deletion doc/api/next_api_changes/behavior/00001-ABC.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ Behavior Change template
Enter description here....

Please rename file with PR number and your initials i.e. "99999-ABC.rst"
and ``git add`` the new file.
and ``git add`` the new file.
2 changes: 1 addition & 1 deletion doc/api/next_api_changes/behavior/22639-RA.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ MacOSX backend to use sRGB instead of GenericRGB colorspace
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
MacOSX backend now display sRGB tagged image instead of GenericRGB which is
an older (now deprecated) Apple colorspace. This is the source colorspace
used by ColorSync to convert to the current display profile.
used by ColorSync to convert to the current display profile.
2 changes: 1 addition & 1 deletion doc/api/next_api_changes/behavior/22691-JMK.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ QuadMesh mouseover defaults to False

New in 3.5, `.QuadMesh.get_cursor_data` allows display of data values
under the cursor. However, this can be very slow for large meshes, so
by `.QuadMesh.set_mouseover` defaults to *False*.
by `.QuadMesh.set_mouseover` defaults to *False*.
2 changes: 1 addition & 1 deletion doc/api/next_api_changes/deprecations/22133-OG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

The modules ``matplotlib.AFM``, ``matplotlib.configfont_pattern``, and
``matplotlib.Type1Font`` are considered internal and public access is
deprecated.
deprecated.
2 changes: 1 addition & 1 deletion doc/api/next_api_changes/deprecations/22134-OG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ Modules ``tight_bbox`` and ``tight_layout`` deprecated
------------------------------------------------------

The modules ``matplotlib.tight_bbox`` and ``matplotlib.tight_layout`` are
considered internal and public access is deprecated.
considered internal and public access is deprecated.
2 changes: 1 addition & 1 deletion doc/api/next_api_changes/deprecations/22268-OG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ is deprecated.

For ``is_close_to_int`` use ``math.isclose(x, round(x))`` instead.
For ``is_decade`` use
``y = numpy.log(x)/numpy.log(base); numpy.isclose(y, numpy.round(y))``
``y = numpy.log(x)/numpy.log(base); numpy.isclose(y, numpy.round(y))``
2 changes: 1 addition & 1 deletion doc/api/next_api_changes/deprecations/22345-JK.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ The methods `~.Figure.set_constrained_layout_pads` and
`~.Figure.get_constrained_layout_pads` are will be deprecated in favor of
``figure.get_layout_engine().set()`` and
``figure.get_layout_engine().get()``, and currently emit a
``PendingDeprecationWarning``.
``PendingDeprecationWarning``.
2 changes: 1 addition & 1 deletion doc/api/next_api_changes/development/00001-ABC.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ Development Change template
Enter description here....

Please rename file with PR number and your initials i.e. "99999-ABC.rst"
and ``git add`` the new file.
and ``git add`` the new file.
1 change: 0 additions & 1 deletion doc/api/next_api_changes/development/22205-ES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ being bumped:

This is consistent with our :ref:`min_deps_policy` and `NEP29
<https://numpy.org/neps/nep-0029-deprecation_policy.html>`__

2 changes: 1 addition & 1 deletion doc/api/next_api_changes/removals/00001-ABC.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ Removal Change template
Enter description of methods/classes removed here....

Please rename file with PR number and your initials i.e. "99999-ABC.rst"
and ``git add`` the new file.
and ``git add`` the new file.
4 changes: 2 additions & 2 deletions doc/api/next_api_changes/removals/21980-CC.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ Removed loaded modules logging
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The list of currently loaded modules is no longer logged at the DEBUG level at Matplotlib import time,
because it can produce extensive output and make other valuable DEBUG statements difficult to find.
If you were relying on this please arrange for your own logging (the built-in `sys.modules` can be used to get the currently loaded modules).
because it can produce extensive output and make other valuable DEBUG statements difficult to find.
If you were relying on this please arrange for your own logging (the built-in `sys.modules` can be used to get the currently loaded modules).
2 changes: 1 addition & 1 deletion doc/api/next_api_changes/removals/22516-OG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ be used as a replacement.

In the WX backend, the property ``IDLE_DELAY`` is removed. In addition, the
parameter ``origin`` of ``gui_repaint()`` is removed, as well as the method
``get_canvas()``. No replacements are provided.
``get_canvas()``. No replacements are provided.
1 change: 0 additions & 1 deletion doc/api/patches_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,3 @@ Functions

bbox_artist
draw_bbox

1 change: 0 additions & 1 deletion doc/api/toolkits/mplot3d/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,3 @@ Work is being done to eliminate this issue. For matplotlib v1.1.0, there is
a semi-official manner to modify these parameters. See the note in the
:mod:`.mplot3d.axis3d` section of the mplot3d API documentation for
more information.

1 change: 0 additions & 1 deletion doc/api/transformations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@
interval_contains, interval_contains_open
:show-inheritance:
:special-members:

6 changes: 3 additions & 3 deletions doc/api/tri_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
:show-inheritance:

.. autoclass:: matplotlib.tri.TriInterpolator

.. autoclass:: matplotlib.tri.LinearTriInterpolator
:members: __call__, gradient
:show-inheritance:
Expand All @@ -30,7 +30,7 @@

.. autoclass:: matplotlib.tri.UniformTriRefiner
:show-inheritance:
:members:
:members:

.. autoclass:: matplotlib.tri.TriAnalyzer
:members:
:members:
18 changes: 9 additions & 9 deletions doc/devel/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ difficulty. ``Difficulty: Easy`` is suited for people with little Python experie
``Difficulty: Medium`` and ``Difficulty: Hard`` are not trivial to solve and
require more thought and programming experience.

In general, the Matplotlib project does not assign issues. Issues are
"assigned" or "claimed" by opening a PR; there is no other assignment
mechanism. If you have opened such a PR, please comment on the issue thread to
avoid duplication of work. Please check if there is an existing PR for the
issue you are addressing. If there is, try to work with the author by
submitting reviews of their code or commenting on the PR rather than opening
a new PR; duplicate PRs are subject to being closed. However, if the existing
PR is an outline, unlikely to work, or stalled, and the original author is
unresponsive, feel free to open a new PR referencing the old one.
In general, the Matplotlib project does not assign issues. Issues are
"assigned" or "claimed" by opening a PR; there is no other assignment
mechanism. If you have opened such a PR, please comment on the issue thread to
avoid duplication of work. Please check if there is an existing PR for the
issue you are addressing. If there is, try to work with the author by
submitting reviews of their code or commenting on the PR rather than opening
a new PR; duplicate PRs are subject to being closed. However, if the existing
PR is an outline, unlikely to work, or stalled, and the original author is
unresponsive, feel free to open a new PR referencing the old one.

.. _submitting-a-bug-report:

Expand Down
11 changes: 10 additions & 1 deletion doc/devel/development_setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,18 @@ These will automatically check flake8 and other style issues when you run
``git commit``. The hooks are defined in the top level
``.pre-commit-config.yaml`` file. To install the hooks ::

pip install pre-commit
python -m pip install pre-commit
pre-commit install

The hooks can also be run manually. All the hooks can be run, in order as
listed in ``.pre-commit-config.yaml``, against the full codebase with ::

pre-commit run --all-files

To run a particular hook manually, run ``pre-commit run`` with the hook id ::

pre-commit run <hook id> --all-files
Comment on lines +73 to +80
Copy link
Contributor Author

Choose a reason for hiding this comment

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

You can of course target particular files with --file (e.g. pre-commit run --file README.rst) but given that is already done on the files that you're attempting to commit when you have pre-commit installed locally this didn't really seem important to note.

From pre-commit run --help:

  --files [FILES ...]   Specific filenames to run hooks on.


Installing additional dependencies for development
==================================================
See :ref:`development-dependencies`.
1 change: 0 additions & 1 deletion doc/devel/style_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -406,4 +406,3 @@ resources contain common best practices for writing documentation.
* `Google Developer Style Guide <https://developers.google.com/style>`_
* `IBM Style Guide <https://www.oreilly.com/library/view/the-ibm-style/9780132118989/>`_
* `Red Hat Style Guide <https://stylepedia.net/style/#grammar>`_

1 change: 0 additions & 1 deletion doc/devel/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -256,4 +256,3 @@ The test discovery scope can be narrowed to single test modules or even single
functions::

python -m pytest --pyargs matplotlib.tests.test_simplification.py::test_clipping

2 changes: 1 addition & 1 deletion doc/missing-references.json
Original file line number Diff line number Diff line change
Expand Up @@ -1107,4 +1107,4 @@
"lib/mpl_toolkits/mplot3d/axes3d.py:docstring of mpl_toolkits.mplot3d.axes3d.Axes3D.get_ylim3d:24"
]
}
}
}
2 changes: 1 addition & 1 deletion doc/users/explain/fonts.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.. redirect-from:: /users/fonts

Fonts in Matplotlib text engine
===============================

Expand Down
2 changes: 1 addition & 1 deletion doc/users/faq/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
.. redirect-from:: /faq/index

##########################
How-to and troubleshooting
How-to and troubleshooting
##########################

.. only:: html
Expand Down
2 changes: 1 addition & 1 deletion doc/users/github_stats.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Pull Requests (84):
* :ghpull:`21908`: Backport PR #21834 on branch v3.5.x (MAINT Fix signature qhull version function )
* :ghpull:`21907`: Backport PR #21905 on branch v3.5.x (Fix image testing decorator in pytest importlib mode)
* :ghpull:`21906`: Backport PR #21773 on branch v3.5.x (FIX: Reset label of axis to center)
* :ghpull:`21834`: MAINT Fix signature qhull version function
* :ghpull:`21834`: MAINT Fix signature qhull version function
* :ghpull:`21905`: Fix image testing decorator in pytest importlib mode
* :ghpull:`21773`: FIX: Reset label of axis to center
* :ghpull:`21902`: Backport PR #21884 on branch v3.5.x (FIX: be more careful about coercing unit-full containers to ndarray)
Expand Down
2 changes: 1 addition & 1 deletion doc/users/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Tutorials and examples
../tutorials/index.rst
../gallery/index.rst

Reference
Reference
#########

.. toctree::
Expand Down
2 changes: 1 addition & 1 deletion doc/users/next_whats_new/3d_plot_roll_angle.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ existing 3D plots.

.. plot::
:include-source: true

from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
fig = plt.figure()
Expand Down
Loading