1
- .. raw :: html
2
-
3
- <style >
4
- .checklist { list-style : none ; padding : 0 ; margin : 0 ; }
5
- .checklist li { margin-left : 24px ; padding-left : 23px ; margin-right : 6px ; }
6
- .checklist li :before { content : " \2610\2001 " ; margin-left : -24px ; }
7
- .checklist li p {display : inline ; }
8
- </style >
9
-
10
1
.. _pr-guidelines :
11
2
12
3
***********************
@@ -17,144 +8,82 @@ Pull request guidelines
17
8
<https://docs.github.com/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests> `__
18
9
are the mechanism for contributing to Matplotlib's code and documentation.
19
10
20
- It is recommended to check that your contribution complies with the following
21
- rules before submitting a pull request:
11
+ We value contributions from people with all levels of experience. In particular,
12
+ if this is your first PR not everything has to be perfect. We'll guide you
13
+ through the PR process. Nevertheless, please try to follow our guidelines as well
14
+ as you can to help make the PR process quick and smooth. If your pull request is
15
+ incomplete or a work-in-progress, please mark it as a `draft pull requests <https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests#draft-pull-requests >`_
16
+ on GitHub and specify what feedback from the developers would be helpful.
22
17
23
- * If your pull request addresses an issue, please use the title to describe the
24
- issue (e.g. "Add ability to plot timedeltas") and mention the issue number
25
- in the pull request description to ensure that a link is created to the
26
- original issue (e.g. "Closes #8869" or "Fixes #8869"). This will ensure the
27
- original issue mentioned is automatically closed when your PR is merged. See
28
- `the GitHub documentation
29
- <https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue> `__
30
- for more details.
18
+ Please be patient with reviewers. We try our best to respond quickly, but we have
19
+ limited bandwidth. If there is no feedback within a couple of days, please ping
20
+ us by posting a comment to your PR.
31
21
32
- * Formatting should follow the recommendations of PEP8 _, as enforced by
33
- flake8 _. Matplotlib modifies PEP8 to extend the maximum line length to 88
34
- characters. You can check flake8 compliance from the command line with ::
35
22
36
- python -m pip install flake8
37
- flake8 /path/to/module.py
38
-
39
- or your editor may provide integration with it. Note that Matplotlib
40
- intentionally does not use the black _ auto-formatter (1 __), in particular due
41
- to its inability to understand the semantics of mathematical expressions
42
- (2 __, 3 __).
23
+ Summary for pull request authors
24
+ ================================
43
25
44
- .. _PEP8 : https://www.python.org/dev/peps/pep-0008/
45
- .. _flake8 : https://flake8.pycqa.org/
46
- .. _black : https://black.readthedocs.io/
47
- .. __ : https://github.com/matplotlib/matplotlib/issues/18796
48
- .. __ : https://github.com/psf/black/issues/148
49
- .. __ : https://github.com/psf/black/issues/1984
26
+ We recommend that you check that your contribution complies with the following
27
+ guidelines before submitting a pull request:
50
28
51
- * All public methods should have informative docstrings with sample usage when
52
- appropriate. Use the :ref: `docstring standards <writing-docstrings >`.
53
-
54
- * For high-level plotting functions, consider adding a simple example either in
55
- the ``Example `` section of the docstring or the
56
- :ref: `examples gallery <gallery >`.
29
+ .. rst-class :: checklist
57
30
58
- * Changes ( both new features and bugfixes) should have good test coverage. See
31
+ * Changes, both new features and bugfixes, should have good test coverage. See
59
32
:ref: `testing ` for more details.
60
33
61
- * Import the following modules using the standard scipy conventions::
62
-
63
- import numpy as np
64
- import numpy.ma as ma
65
- import matplotlib as mpl
66
- import matplotlib.pyplot as plt
67
- import matplotlib.cbook as cbook
68
- import matplotlib.patches as mpatches
69
-
70
- In general, Matplotlib modules should **not** import `.rcParams` using ``from
71
- matplotlib import rcParams``, but rather access it as ``mpl.rcParams``. This
72
- is because some modules are imported very early, before the `.rcParams`
73
- singleton is constructed.
74
-
75
- * If your change is a major new feature, add an entry to the ``What's new ``
76
- section by adding a new file in ``doc/users/next_whats_new `` (see
77
- :file: `doc/users/next_whats_new/README.rst ` for more information).
78
-
79
- * If you change the API in a backward-incompatible way, please document it in
80
- :file: `doc/api/next_api_changes/behavior `, by adding a new file with the
81
- naming convention ``99999-ABC.rst `` where the pull request number is followed
82
- by the contributor's initials. (see :file: `doc/api/api_changes.rst ` for more
83
- information)
84
-
85
- * If you add new public API or change public API, update or add the
86
- corresponding type hints. Most often this is found in the corresponding
87
- ``.pyi `` file for the ``.py `` file which was edited. Changes in ``pyplot.py ``
88
- are type hinted inline.
89
-
90
- * See below for additional points about :ref: `keyword-argument-processing `, if
91
- applicable for your pull request.
92
-
93
- .. note ::
34
+ * Update the :ref: `documentation <pr-documentation >` if necessary.
94
35
95
- The current state of the Matplotlib code base is not compliant with all
96
- of these guidelines, but we expect that enforcing these constraints on all
97
- new contributions will move the overall code base quality in the right
98
- direction.
36
+ * All public methods should have informative docstrings with sample usage when
37
+ appropriate. Use the :ref: `docstring standards <writing-docstrings >`.
99
38
39
+ * For high-level plotting functions, consider adding a small example to the
40
+ :ref: `examples gallery <gallery >`.
100
41
101
- .. seealso ::
42
+ * If you add a major new feature or change the API in a backward-incompatible
43
+ way, please document it as described in :ref: `api_whats_new `
102
44
103
- * :ref: `coding_guidelines `
104
- * :ref: `testing `
105
- * :ref: `documenting-matplotlib `
45
+ * Code should follow our conventions as documented in our :ref: `coding-standards `
106
46
47
+ * When adding or changing public function signatures, add :ref: `type hints <type-hints >`
107
48
49
+ * When adding keyword arguments, see our guide to :ref: `keyword-argument-processing `.
108
50
109
- Summary for pull request authors
110
- ================================
51
+ When opening a pull request on Github, please ensure that:
111
52
112
- .. note ::
53
+ .. rst-class :: checklist
113
54
114
- * We value contributions from people with all levels of experience. In
115
- particular if this is your first PR not everything has to be perfect.
116
- We'll guide you through the PR process.
117
- * Nevertheless, please try to follow the guidelines below as well as you can to
118
- help make the PR process quick and smooth.
119
- * Be patient with reviewers. We try our best to respond quickly, but we
120
- have limited bandwidth. If there is no feedback within a couple of days,
121
- please ping us by posting a comment to your PR.
55
+ * Changes were made on a :ref: `feature branch <make-feature-branch >`.
122
56
123
- When making a PR, pay attention to:
57
+ * :ref: ` pre-commit < pre-commit-hooks >` checks for spelling, formatting, etc pass
124
58
125
- .. rst-class :: checklist
59
+ * The pull request targets the :ref: ` main branch < pr-branch-selection >`
126
60
127
- * :ref: `Target the main branch <pr-branch-selection >`.
128
- * Adhere to the :ref: `coding_guidelines `.
129
- * Update the :ref: `documentation <pr-documentation >` if necessary.
130
- * Aim at making the PR as "ready-to-go" as you can. This helps to speed up
131
- the review process.
132
- * It is ok to open incomplete or work-in-progress PRs if you need help or
133
- feedback from the developers. You may mark these as
134
- `draft pull requests <https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests#draft-pull-requests >`_
135
- on GitHub.
136
- * When updating your PR, instead of adding new commits to fix something, please
137
- consider amending your initial commit(s) to keep the history clean.
138
- You can achieve this by using
61
+ * If your pull request addresses an issue, please use the title to describe the
62
+ issue (e.g. "Add ability to plot timedeltas") and mention the issue number
63
+ in the pull request description to ensure that a link is created to the
64
+ original issue (e.g. "Closes #8869" or "Fixes #8869"). This will ensure the
65
+ original issue mentioned is automatically closed when your PR is merged. For more
66
+ details, see `linking an issue and pull request <https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue >`__.
139
67
140
- .. code-block :: bash
68
+ * :ref: ` pr-automated-tests ` pass
141
69
142
- git commit --amend --no-edit
143
- git push [your-remote-repo] [your-branch] --force-with-lease
70
+ For guidance on creating and managing a pull request, please see our
71
+ :ref: `contributing <contributing >` and :ref: `pull request workflow <edit-flow >`
72
+ guides.
144
73
145
- See also :ref: `contributing ` for how to make a PR.
146
74
147
75
Summary for pull request reviewers
148
76
==================================
149
77
150
78
.. redirect-from :: /devel/maintainer_workflow
151
79
152
- .. note ::
80
+ ** Please help review and merge PRs! **
153
81
154
- * If you have commit rights, then you are trusted to use them.
155
- **Please help review and merge PRs! **
156
- * Be patient and `kind <https://youtu.be/tzFWz5fiVKU?t=49m30s >`__ with
157
- contributors.
82
+ If you have commit rights, then you are trusted to use them. Please be patient
83
+ and `kind <https://youtu.be/tzFWz5fiVKU?t=49m30s >`__ with contributors.
84
+
85
+ When reviewing, please ensure that the pull request satisfies the following
86
+ requirements before merging it:
158
87
159
88
Content topics:
160
89
@@ -187,6 +116,88 @@ Organizational topics:
187
116
Detailed guidelines
188
117
===================
189
118
119
+ .. _coding-standards :
120
+
121
+ Coding style guide
122
+ ------------------
123
+
124
+ While the current state of the Matplotlib code base is not compliant with all
125
+ of these guidelines, but our goal in enforcing these constraints on new
126
+ contributions is that it improves the readability and consistency of the code base
127
+ going forward.
128
+
129
+ PEP8, as enforced by flake8
130
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^
131
+
132
+ Formatting should follow the recommendations of PEP8 _, as enforced by flake8 _.
133
+ Matplotlib modifies PEP8 to extend the maximum line length to 88
134
+ characters. You can check flake8 compliance from the command line with ::
135
+
136
+ python -m pip install flake8
137
+ flake8 /path/to/module.py
138
+
139
+ or your editor may provide integration with it. Note that Matplotlib intentionally
140
+ does not use the black _ auto-formatter (1 __), in particular due to its inability
141
+ to understand the semantics of mathematical expressions (2 __, 3 __).
142
+
143
+ .. _PEP8 : https://www.python.org/dev/peps/pep-0008/
144
+ .. _flake8 : https://flake8.pycqa.org/
145
+ .. _black : https://black.readthedocs.io/
146
+ .. __ : https://github.com/matplotlib/matplotlib/issues/18796
147
+ .. __ : https://github.com/psf/black/issues/148
148
+ .. __ : https://github.com/psf/black/issues/1984
149
+
150
+
151
+ Package imports
152
+ ^^^^^^^^^^^^^^^
153
+ Import the following modules using the standard scipy conventions::
154
+
155
+ import numpy as np
156
+ import numpy.ma as ma
157
+ import matplotlib as mpl
158
+ import matplotlib.pyplot as plt
159
+ import matplotlib.cbook as cbook
160
+ import matplotlib.patches as mpatches
161
+
162
+ In general, Matplotlib modules should **not ** import `.rcParams ` using ``from
163
+ matplotlib import rcParams ``, but rather access it as ``mpl.rcParams ``. This
164
+ is because some modules are imported very early, before the `.rcParams `
165
+ singleton is constructed.
166
+
167
+ Naming variables
168
+ ^^^^^^^^^^^^^^^^
169
+ When feasible, please use our internal variable naming convention for objects
170
+ of a given class and objects of any child class:
171
+
172
+ +---------------+------------------------------------+
173
+ | variable name | base class |
174
+ +===============+====================================+
175
+ | ``fig `` | `~matplotlib.figure.FigureBase ` |
176
+ +---------------+------------------------------------+
177
+ | ``ax `` | `~matplotlib.axes.Axes ` |
178
+ +---------------+------------------------------------+
179
+ | ``trans `` | `~matplotlib.transforms.Transform ` |
180
+ +---------------+------------------------------------+
181
+
182
+ Generally, denote more than instance of the same class by adding numbers to
183
+ the variable names, i.e. ``trans1 ``, ``trans2 ``.
184
+
185
+ .. _type-hints :
186
+
187
+ Type hints
188
+ ^^^^^^^^^^
189
+
190
+ If you add new public API or change public API, update or add the
191
+ corresponding `mypy <https://mypy.readthedocs.io/en/latest/ >`_ type hints.
192
+ Most often this is found in the corresponding ``.pyi `` file for the edited
193
+ ``.py `` file, for example ``colors.py `` and ``colors.pyi ``. Changes in ``pyplot.py ``
194
+ are type hinted inline.
195
+
196
+ Type hints are checked by the mypy :ref: `pre-commit hook <pre-commit-hooks >`
197
+ and can often be verified using ``tools\stubtest.py `` and occasionally may
198
+ require the use of ``tools\check_typehints.py ``.
199
+
200
+
190
201
.. _pr-documentation :
191
202
192
203
Documentation
@@ -205,7 +216,7 @@ Documentation
205
216
206
217
* See :ref: `documenting-matplotlib ` for our documentation style guide.
207
218
208
- .. _ release_notes :
219
+ .. _ api_whats_new :
209
220
210
221
New features and API changes
211
222
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -223,6 +234,10 @@ and adding an entry to the folder for either the what's new or API change notes.
223
234
| | | probably in ``behavior/ `` |
224
235
+-------------------+-----------------------------+----------------------------------+
225
236
237
+ The API change note should be named ``99999-ABC.rst `` where the pull request
238
+ number is followed by the contributor's initials. For more information, see
239
+ :file: `doc/api/api_changes.rst ` and :file: `doc/users/next_whats_new/README.rst `.
240
+
226
241
The directives should be placed at the end of a description block. For example::
227
242
228
243
class Foo:
0 commit comments