Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[MNT]: Remove 3.7-deprecated API #26865

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
14 tasks done
QuLogic opened this issue Sep 22, 2023 · 12 comments · Fixed by #26962
Closed
14 tasks done

[MNT]: Remove 3.7-deprecated API #26865

QuLogic opened this issue Sep 22, 2023 · 12 comments · Fixed by #26962
Labels
Difficulty: Easy https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues Good first issue Open a pull request against these issues if there are no active ones! Maintenance mentored: hackathon
Milestone

Comments

@QuLogic
Copy link
Member

QuLogic commented Sep 22, 2023

Summary

As old and unused API (classes, methods, functions) are found, they are marked deprecated with removal intended in a later release. These API are decorated or otherwise wrapped with the deprecation functions in _api (i.e., deprecated, warn_deprecated, rename_parameter, delete_parameter, make_keyword_only, deprecate_method_override, or deprecate_privatize_attribute).

Now that 3.8 is out and main targets 3.9, we can start the process of removing API that were deprecated in 3.7 (i.e., those with since="3.7" and without pending=True).

Proposed fix

Each part of the deprecated API should be removed:

  1. The deprecated code itself:
    a. Items marked with _api.warn_deprecated, @_api.deprecated or @_api.deprecate_privatize_attribute are to be removed on expiry, i.e., any of the marked lines below:
    -@api.deprecated("3.7", ...)
    -def foo():
    -    pass
    
     def bar(x):
         if x is None:
    -        _api.warn_deprecated("3.7", message="x=None is deprecated")
    +        raise ValueError("x=None is not supported")
        ...
    
     class Baz:
          ...
    -     value = _api.deprecate_privatize_attribute("3.7", ...)
    b. Items decorated with @_api.rename_parameter should have this decorator removed, and no other changes will be necessary (the parameter rename should already have been made when the decorator was added.), i.e.,
    -@_api.rename_parameter("3.7", "old_name", "new_name")
     def foo(new_name):
        ...
    c. Items decorated with @_api.make_keyword_only should have the decorator removed, and the parameter named there should be made keyword-only (by adding a * before that point).
    -@_api.make_keyword_only("3.7", "arg3")
    -def foo(arg1, arg2, arg3, arg4):
    +def foo(arg1, arg2, *, arg3, arg4):
        ...
    d. Items decorated with @_api.delete_parameter will need to have the parameter deleted and all following parameters made keyword-only.
    -@_api.delete_parameter("3.7", "arg3")
    -def foo(arg1, arg2, arg3, arg4):
    +def foo(arg1, arg2, *, arg4):
        ...
  2. The corresponding type stub in the related *.pyi file.
  3. Any tests for only deprecated behaviour.
  4. Any related exceptions in ci/mypy-stubtest-allowlist.txt, if there are any.

Additionally, the removal should be documented by placing a snippet in doc/api/next_api_changes/removals/ (see 00001-ABC.rst in that directory for a template). For writing these snippets, you may wish to copy the original deprecation notice, modifying it slightly to state that the API has been removed instead. Please ensure that any references to deleted API include a full path (as there may be many methods with the same name, but on different classes.)

NOTE: After removing the deprecated API, there may be some additional fallout that should be corrected. For example,

  1. Removed code may be aliased by importing in another location, so those imports will have to be removed.
  2. Documentation may link to the removed API; these should be kept in code style. For example,
    This is some text referencing :class:`.RemovedClass`.
    should be changed to:
    This is some text referencing ``matplotlib.submodule.RemovedClass``.
    (Please expand the API into the full import name.)

See also our documentation on removing deprecated API and #26853 for an example removing several types of deprecated API.

Task list

A quick search shows the following sets of possible parts to remove (for GHC OSD, please use Slack and/or Zoom to make sure someone else hasn't started working on the same set):

  1. lib/matplotlib/animation.py - 2 deprecations Deprecated code removed in animation.py #26872
  2. lib/matplotlib/axis.py - 1 deprecation Removed the deprecated code from axis.py #26871
  3. lib/matplotlib/backends/*.py - 3 deprecations and src/_backend_agg_wrapper.cpp - 2 deprecations Remove backend 3.7-deprecated API  #26962
  4. lib/matplotlib/cm.py - 2 deprecations (Note: the documentation for this removal may be a bit tricky to write.) Removal of deprecated API cm #26965
  5. lib/matplotlib/contour.py - 5 deprecations Removal of deprecations for Contour #26907
  6. lib/matplotlib/collections.py - 2 deprecations Cleaned up the span_where class method from Polycollections. #26874
  7. lib/matplotlib/_fontconfig_patterns.py - 1 deprecation Remove deprecated code from _fontconfig_patterns #26884
  8. lib/matplotlib/gridspec.py - 1 deprecation Removed deprecated code from gridspec.py #26885 (!)
  9. lib/matplotlib/lines.py - 2 deprecations Fixed deprecated APIs in lines.py #26902
  10. lib/matplotlib/offsetbox.py - 3 deprecations Removed the deprecated code from offsetbox.py #26910 Updated offsetbox.py #26880
  11. lib/matplotlib/patches.py - 1 deprecation Removing deprecated api from patches #26890 issue: 26871 - Remove SimplePath class from patches.py #26876 #26865 removing deprecations to axislines.py #26900 (!)
  12. lib/matplotlib/quiver.py - 2 deprecations 26865 Removed deprecations from quiver.py #26918
  13. lib/matplotlib/tri/*.py - 8 deprecations deprecated api tri #26909
  14. lib/mpl_toolkits/axisartist/axislines.py - 2 deprecations #26865 removing deprecations to axislines.py #26900

There may be some other items I've missed here, but note that we do not want to remove any with pending=True, or since="3.8" or higher.

@QuLogic QuLogic added mentored: hackathon Difficulty: Easy https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues Good first issue Open a pull request against these issues if there are no active ones! Maintenance labels Sep 22, 2023
@QuLogic QuLogic added this to the v3.9.0 milestone Sep 22, 2023
@github-actions
Copy link

Good first issue - notes for new contributors

This issue is suited to new contributors because it does not require understanding of the Matplotlib internals. To get started, please see our contributing guide.

We do not assign issues. Check the Development section in the sidebar for linked pull requests (PRs). If there are none, feel free to start working on it. If there is an open PR, please collaborate on the work by reviewing it rather than duplicating it in a competing PR.

If something is unclear, please reach out on any of our communication channels.

@QuLogic
Copy link
Member Author

QuLogic commented Sep 22, 2023

If there is an open PR, please collaborate on the work by reviewing it rather than duplicating it in a competing PR.

Note that we expect to have PRs for smaller chunks here, so even if there are open ones, there might still be some chance to work on this issue; see the checklist above.

@DHClimber
Copy link
Contributor

Change in progress lib/matplotlib/contour.py #

@GAuravY19
Copy link

Hi,
I am a beginner t0 open-source contributions. I want to start my open-source contribution journey with this issue.

Can anyone please tell me how I should start with this issue...?

@GAuravY19
Copy link

Hi Sir,

For the first time, I am doing open source contribution.
I have tried to remove the deprecated function from src/_backend_agg_wrapper.cpp.

I want to share with you my work so that I can know whether I have the right job or not. Will you please guide me with the steps to create a pull request and send you my work for reviewing?

@GAuravY19
Copy link

It would be very helpful if you also guide me with what I have done wrong and how I can correct it.

@ksunden
Copy link
Member

ksunden commented Sep 29, 2023

Please see our contributing guide

@QuLogic
Copy link
Member Author

QuLogic commented Dec 6, 2023

Not quite finished.

@Yen-yen
Copy link

Yen-yen commented Feb 1, 2024

Hi,
This will be my first contribution. After reading the contributing guide, I would like to start with this. Is anyone working on this right now?

@tacaswell
Copy link
Member

@Yen-yen I think we have open PRs for all of these already. This may not be a good issue to start on right now.

@Yen-yen
Copy link

Yen-yen commented Feb 1, 2024

@Yen-yen I think we have open PRs for all of these already. This may not be a good issue to start on right now.

Got it. Thank you so much. I will look into another one!

@QuLogic
Copy link
Member Author

QuLogic commented Feb 8, 2024

I believe this is now complete.

@QuLogic QuLogic closed this as completed Feb 8, 2024
@rcomer rcomer mentioned this issue Mar 3, 2024
4 tasks
QuLogic added a commit to QuLogic/matplotlib that referenced this issue Mar 23, 2024
Not sure why I missed listing these in matplotlib#26865.
QuLogic added a commit to QuLogic/matplotlib that referenced this issue Mar 23, 2024
Not sure why I missed listing these in matplotlib#26865.
QuLogic added a commit to QuLogic/matplotlib that referenced this issue Mar 23, 2024
Not sure why I missed listing these in matplotlib#26865.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Difficulty: Easy https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues Good first issue Open a pull request against these issues if there are no active ones! Maintenance mentored: hackathon
Projects
None yet
6 participants