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

Skip to content

Fix incorrect usage of nargs_error. #25863

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 1 commit into from
May 11, 2023
Merged

Fix incorrect usage of nargs_error. #25863

merged 1 commit into from
May 11, 2023

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented May 11, 2023

nargs_error simply returns the exception, the caller needs to throw it.

PR summary

PR checklist

nargs_error simply returns the exception, the caller needs to throw it.
Copy link
Member

@oscargus oscargus left a comment

Choose a reason for hiding this comment

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

I guess these are not tested then?

@story645 story645 added this to the v3.7.2 milestone May 11, 2023
@anntzer
Copy link
Contributor Author

anntzer commented May 11, 2023

No tests, but I'll leave adding tests as an exercise to the reader.

@story645 story645 merged commit 544d8ce into matplotlib:main May 11, 2023
@lumberbot-app
Copy link

lumberbot-app bot commented May 11, 2023

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
git checkout v3.7.x
git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
git cherry-pick -x -m1 544d8cef2a00f243228f09c1f0dea3ee0e8409c1
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
git commit -am 'Backport PR #25863: Fix incorrect usage of nargs_error.'
  1. Push to a named branch:
git push YOURFORK v3.7.x:auto-backport-of-pr-25863-on-v3.7.x
  1. Create a PR against branch v3.7.x, I would have named this PR:

"Backport PR #25863 on branch v3.7.x (Fix incorrect usage of nargs_error.)"

And apply the correct labels and milestones.

Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon!

Remember to remove the Still Needs Manual Backport label once the PR gets merged.

If these instructions are inaccurate, feel free to suggest an improvement.

@tacaswell
Copy link
Member

tacaswell commented May 11, 2023

This bug is not on the 3.7.x branch, merge failures look like

@@@ -314,7 -321,7 +314,11 @@@ class Axes(_AxesBase)
                  *args,
                  **kwargs)
          if len(extra_args):
++<<<<<<< HEAD
 +            raise TypeError('legend only accepts two non-keyword arguments')
++=======
+             raise _api.nargs_error('legend', '0-2', len(args))
++>>>>>>> 544d8cef2a (Merge pull request #25863 from anntzer/ne)
          self.legend_ = mlegend.Legend(self, handles, labels, **kwargs)
          self.legend_._remove_method = self._remove_legend
          return self.legend_
@@@ -2978,8 -3005,7 +2982,12 @@@
              which inspired this method.
          """
          if not 1 <= len(args) <= 3:
++<<<<<<< HEAD
 +            raise TypeError('stem expected between 1 or 3 positional '
 +                            'arguments, got {}'.format(args))
++=======
+             raise _api.nargs_error('stem', '1-3', len(args))
++>>>>>>> 544d8cef2a (Merge pull request #25863 from anntzer/ne)
          _api.check_in_list(['horizontal', 'vertical'], orientation=orientation)
  
          if len(args) == 1:
@@@ -6396,7 -6422,7 +6404,11 @@@ default: :rc:`scatter.edgecolors
              else:
                  raise TypeError("arguments do not match valid signatures")
          else:
++<<<<<<< HEAD
 +            raise TypeError("need 1 argument or 3 arguments")
++=======
+             raise _api.nargs_error('pcolorfast', '1 or 3', len(args))
++>>>>>>> 544d8cef2a (Merge pull request #25863 from anntzer/ne)
  
          if style == "quadmesh":
              # data point in each cell is value at lower left corner

@QuLogic
Copy link
Member

QuLogic commented May 12, 2023

This bug is not on the 3.7.x branch, merge failures look like

Yep, this was my fault in #25609, and it was not backported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants