Skip to content

Mypy gradual #1

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

Closed
wants to merge 45 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
f063fd2
Fix polar transform with non-linear scales
dstansby Dec 27, 2022
e5cfa0f
Add docs for polar transform
dstansby Dec 27, 2022
c8f2017
Add a polar log test
dstansby Dec 27, 2022
d775dad
Fix line widths
dstansby Dec 27, 2022
6005a51
Math formatting in PolarTransform docstring
dstansby Dec 28, 2022
a0d4e6b
Fix indentation
dstansby Jan 3, 2023
fd6604d
Remove contour warning for "no-valid-levels".
anntzer Jan 9, 2023
ca48799
Remove remaining deprecations from 3.5
QuLogic Jan 11, 2023
8482fc2
MNT: remove check that exists only for removed deprecation
tacaswell Jan 11, 2023
90dfdbc
TST: remove tests of (now expired) deprecation warnings
tacaswell Jan 11, 2023
dfbaaa8
MNT: remove orphaned module attribute
tacaswell Jan 11, 2023
6f9c155
DOC: tweak wording on ArtistList class docstring
tacaswell Jan 11, 2023
a5d95fe
DOC: add notes for removals
tacaswell Jan 11, 2023
293ccc2
DOC: Enable Opensearch
StefRe Jan 12, 2023
a24daae
Rename y -> r
oscargus Jan 12, 2023
aa426be
Expire deprecations in widgets and keyword only arguments for Selecto…
oscargus Jan 12, 2023
ba03951
Merge pull request #24825 from dstansby/polar-scales
oscargus Jan 12, 2023
244a01c
Merge pull request #24948 from QuLogic/remove-deprecations
oscargus Jan 12, 2023
cf1b601
Merge pull request #24957 from StefRe/patch-1
jklymak Jan 12, 2023
018c5ef
Merge pull request #24912 from anntzer/cw
oscargus Jan 12, 2023
c1a8406
Remove additional deprecations from 3.5
QuLogic Jan 13, 2023
a3011df
Merge pull request #24965 from QuLogic/more-deprecations
oscargus Jan 13, 2023
a762ae6
MNT: Fix double % signs in matplotlibrc
StefRe Jan 13, 2023
3c28528
FIX: adjust_bbox should not modify layout engine
rcomer Jan 13, 2023
90fe9e0
Merge pull request #24973 from StefRe/patch-1
tacaswell Jan 13, 2023
235b01f
Merge pull request #24971 from rcomer/adjust_bbox-layout-engine
tacaswell Jan 13, 2023
a16ccba
Initially make mypy pass for tests
ksunden Dec 7, 2022
6acaa96
Insert the majority of the pyi stub files
ksunden Dec 9, 2022
e893af4
__init__.pyi, add __all__ to __init__
ksunden Dec 14, 2022
ada190c
Add mypy to reviewdog workflow
ksunden Dec 27, 2022
aa53a0c
Add __future__ imports to tests where inline type hints are included
ksunden Dec 27, 2022
1c94024
Update boilerplate to include annotations from pyi files
ksunden Jan 3, 2023
4be90ab
pyplot autogenerated bits with annotations
ksunden Jan 3, 2023
ea5d6d4
Use black for autogenerated portions of pyplot. remove textwrap usage
ksunden Jan 5, 2023
eaf2c43
Type handwritten portion of pyplot
ksunden Jan 4, 2023
0301057
Update for api changes since mypy branch was started
ksunden Jan 5, 2023
77952eb
STY: run black over pyi stub files
ksunden Jan 6, 2023
bbd4c33
Make Color a union type of 3/4-tuple of floats and str
ksunden Jan 6, 2023
d39a907
Resolve some typing todos
ksunden Jan 6, 2023
a94caab
Update Axes.pyi pie stub to include hatch, regenerate pyplot with hat…
ksunden Jan 11, 2023
8e5a30a
Redistribute types defined in _typing to their logical homes
ksunden Jan 11, 2023
117949f
Get sphinx building without errors
ksunden Jan 12, 2023
8bc7f1f
Update for expired 3.5 deprecations
ksunden Jan 13, 2023
5b02469
Boilerplate.py review comments
ksunden Jan 16, 2023
d832950
Review and CI warnings
ksunden Jan 17, 2023
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
2 changes: 2 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ exclude_lines =
def __str__
def __repr__
if __name__ == .__main__.:
if TYPE_CHECKING:
if typing.TYPE_CHECKING:
34 changes: 34 additions & 0 deletions .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,40 @@ jobs:
flake8 --docstring-convention=all | \
reviewdog -f=pep8 -name=flake8 \
-tee -reporter=github-check -filter-mode nofilter
mypy:
name: mypy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Python 3
uses: actions/setup-python@v4
with:
python-version: 3.8

- name: Install mypy
run: pip3 install -r requirements/testing/mypy.txt -r requirements/testing/all.txt

- name: Set up reviewdog
run: |
mkdir -p "$HOME/bin"
curl -sfL \
https://github.com/reviewdog/reviewdog/raw/master/install.sh | \
sh -s -- -b "$HOME/bin"
echo "$HOME/bin" >> $GITHUB_PATH

- name: Run mypy
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -o pipefail
# the ignore missing imports can be removed when typed cycler is released and used
mypy --config pyproject.toml lib/matplotlib \
--ignore-missing-imports \
--follow-imports silent | \
reviewdog -f=mypy -name=mypy \
-tee -reporter=github-check -filter-mode nofilter


eslint:
name: eslint
Expand Down
1 change: 1 addition & 0 deletions doc/api/colors_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Other classes

ColorSequenceRegistry
LightSource
Color

Functions
---------
Expand Down
3 changes: 3 additions & 0 deletions doc/api/lines_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ Classes

Line2D
VertexSelector
LineStyleType
DrawStyleType
MarkEveryType

Functions
---------
Expand Down
2 changes: 2 additions & 0 deletions doc/api/markers_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ Classes
:template: autosummary.rst

MarkerStyle
MarkerType
FillStyleType
4 changes: 4 additions & 0 deletions doc/api/next_api_changes/behavior/24912-AL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
``contour`` no longer warns if no contour lines are drawn.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This can occur if the user explicitly passes a ``levels`` array with no values
between ``z.min()`` and ``z.max()``; or if ``z`` has the same value everywhere.
6 changes: 6 additions & 0 deletions doc/api/next_api_changes/deprecations/24254-OG.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Most arguments to widgets have been made keyword-only
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Passing all but the very few first arguments positionally in the constructors
of Widgets is deprecated. Most arguments will become keyword-only in a future
version.
64 changes: 64 additions & 0 deletions doc/api/next_api_changes/removals/24254-OG.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
Removal of deprecations in the Selector widget API
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

RectangleSelector and EllipseSelector
.....................................

The *drawtype* keyword argument to `~matplotlib.widgets.RectangleSelector` is
removed. From now on, the only behaviour will be ``drawtype='box'``.

Support for ``drawtype=line`` is removed altogether. As a
result, the *lineprops* keyword argument to
`~matplotlib.widgets.RectangleSelector` is also removed.

To retain the behaviour of ``drawtype='none'``, use ``rectprops={'visible':
False}`` to make the drawn `~matplotlib.patches.Rectangle` invisible.

Cleaned up attributes and arguments are:

- The ``active_handle`` attribute has been privatized and removed.
- The ``drawtype`` attribute has been privatized and removed.
- The ``eventpress`` attribute has been privatized and removed.
- The ``eventrelease`` attribute has been privatized and removed.
- The ``interactive`` attribute has been privatized and removed.
- The *marker_props* argument is removed, use *handle_props* instead.
- The *maxdist* argument is removed, use *grab_range* instead.
- The *rectprops* argument is removed, use *props* instead.
- The ``rectprops`` attribute has been privatized and removed.
- The ``state`` attribute has been privatized and removed.
- The ``to_draw`` attribute has been privatized and removed.

PolygonSelector
...............

- The *line* attribute is removed. If you want to change the selector artist
properties, use the ``set_props`` or ``set_handle_props`` methods.
- The *lineprops* argument is removed, use *props* instead.
- The *markerprops* argument is removed, use *handle_props* instead.
- The *maxdist* argument and attribute is removed, use *grab_range* instead.
- The *vertex_select_radius* argument and attribute is removed, use
*grab_range* instead.

SpanSelector
............

- The ``active_handle`` attribute has been privatized and removed.
- The ``eventpress`` attribute has been privatized and removed.
- The ``eventrelease`` attribute has been privatized and removed.
- The ``pressv`` attribute has been privatized and removed.
- The ``prev`` attribute has been privatized and removed.
- The ``rect`` attribute has been privatized and removed.
- The *rectprops* parameter has been renamed to *props*.
- The ``rectprops`` attribute has been privatized and removed.
- The *span_stays* parameter has been renamed to *interactive*.
- The ``span_stays`` attribute has been privatized and removed.
- The ``state`` attribute has been privatized and removed.

LassoSelector
.............

- The *lineprops* argument is removed, use *props* instead.
- The ``onpress`` and ``onrelease`` methods are removed. They are straight
aliases for ``press`` and ``release``.
- The ``matplotlib.widgets.TextBox.DIST_FROM_LEFT`` attribute has been
removed. It was marked as private in 3.5.
115 changes: 115 additions & 0 deletions doc/api/next_api_changes/removals/24948-ES.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@

Testing support
~~~~~~~~~~~~~~~

``matplotlib.test()`` has been removed
......................................

Run tests using ``pytest`` from the commandline instead. The variable
``matplotlib.default_test_modules`` was only used for ``matplotlib.test()`` and
is thus removed as well.

To test an installed copy, be sure to specify both ``matplotlib`` and
``mpl_toolkits`` with ``--pyargs``::

python -m pytest --pyargs matplotlib.tests mpl_toolkits.tests

See :ref:`testing` for more details.



Auto-removal of grids by `~.Axes.pcolor` and `~.Axes.pcolormesh`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

`~.Axes.pcolor` and `~.Axes.pcolormesh` previously remove any visible axes
major grid. This behavior is removed; please explicitly call ``ax.grid(False)``
to remove the grid.



Modification of ``Axes`` children sublists
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

See :ref:`Behavioural API Changes 3.5 - Axes children combined` for more
information; modification of the following sublists is no longer supported:

* ``Axes.artists``
* ``Axes.collections``
* ``Axes.images``
* ``Axes.lines``
* ``Axes.patches``
* ``Axes.tables``
* ``Axes.texts``

To remove an Artist, use its `.Artist.remove` method. To add an Artist, use the
corresponding ``Axes.add_*`` method.

Passing incorrect types to ``Axes.add_*`` methods
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The following ``Axes.add_*`` methods will now raise if passed an unexpected
type. See their documentation for the types they expect.

- `.Axes.add_collection`
- `.Axes.add_image`
- `.Axes.add_line`
- `.Axes.add_patch`
- `.Axes.add_table`


``ConversionInterface.convert`` no longer accepts unitless values
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Previously, custom subclasses of `.units.ConversionInterface` needed to
implement a ``convert`` method that not only accepted instances of the unit,
but also unitless values (which are passed through as is). This is no longer
the case (``convert`` is never called with a unitless value), and such support
in ``.StrCategoryConverter`` is removed. Likewise, the
``.ConversionInterface.is_numlike`` helper is removed.

Consider calling `.Axis.convert_units` instead, which still supports unitless
values.


Normal list of `.Artist` objects now returned by `.HandlerLine2D.create_artists`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

For Matplotlib 3.5 and 3.6 a proxy list was returned that simulated the return
of `.HandlerLine2DCompound.create_artists`. Now a list containing only the
single artist is return.


rcParams will no longer cast inputs to str
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

rcParams that expect a (non-pathlike) str no longer cast non-str inputs using
`str`. This will avoid confusing errors in subsequent code if e.g. a list input
gets implicitly cast to a str.



Case-insensitive scales
~~~~~~~~~~~~~~~~~~~~~~~

Previously, scales could be set case-insensitively (e.g.,
``set_xscale("LoG")``). Now all builtin scales use lowercase names.



Support for ``nx1 = None`` or ``ny1 = None`` in ``AxesLocator`` and ``Divider.locate``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In `.axes_grid1.axes_divider`, various internal APIs no longer supports
passing ``nx1 = None`` or ``ny1 = None`` to mean ``nx + 1`` or ``ny + 1``, in
preparation for a possible future API which allows indexing and slicing of
dividers (possibly ``divider[a:b] == divider.new_locator(a, b)``, but also
``divider[a:] == divider.new_locator(a, <end>)``). The user-facing
`.Divider.new_locator` API is unaffected -- it correctly normalizes ``nx1 =
None`` and ``ny1 = None`` as needed.


change signature of ``.FigureCanvasBase.enter_notify_event``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The *xy* parameter is now required and keyword only. This was deprecated in
3.0 and originally slated to be removed in 3.5.
5 changes: 5 additions & 0 deletions doc/api/next_api_changes/removals/24965-ES.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
``Colorbar`` tick update parameters
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The *update_ticks* parameter of `.Colorbar.set_ticks` and
`.Colorbar.set_ticklabels` was ignored since 3.5 and has been removed.
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ implement a ``convert`` method that not only accepted instances of the unit,
but also unitless values (which are passed through as is). This is no longer
the case (``convert`` is never called with a unitless value), and such support
in `.StrCategoryConverter` is deprecated. Likewise, the
`.ConversionInterface.is_numlike` helper is deprecated.
``.ConversionInterface.is_numlike`` helper is deprecated.

Consider calling `.Axis.convert_units` instead, which still supports unitless
values.
Expand Down
2 changes: 1 addition & 1 deletion doc/api/prev_api_changes/api_changes_3.5.0/removals.rst
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ Arguments
- The *dummy* parameter of `.RendererPgf` has been removed.
- The *props* parameter of `.Shadow` has been removed; use keyword arguments
instead.
- The *recursionlimit* parameter of `matplotlib.test` has been removed.
- The *recursionlimit* parameter of ``matplotlib.test`` has been removed.
- The *label* parameter of `.Tick` has no effect and has been removed.
- `~.ticker.MaxNLocator` no longer accepts a positional parameter and the
keyword argument *nbins* simultaneously because they specify the same
Expand Down
5 changes: 0 additions & 5 deletions doc/api/testing_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
**********************


:func:`matplotlib.test`
=======================

.. autofunction:: matplotlib.test

:mod:`matplotlib.testing`
=========================

Expand Down
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ def js_tag_with_cache_busting(js):

# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it.
html_use_opensearch = 'False'
html_use_opensearch = 'https://matplotlib.org/stable'

# Output file base name for HTML help builder.
htmlhelp_basename = 'Matplotlibdoc'
Expand Down
Loading