Skip to content

Cleaning up variable argument signatures #9912

@timhoffm

Description

@timhoffm

There are a lot of *args, **kwargs signatures in the API. In many cases, they could be better described by explicit arguments/kw-arguments. This makes for a more clear API and reduces the chance of unintended misuse.

For example pyplot.delaxes

def delaxes(*args):
    """..."""
    if not len(args):
        ax = gca()
    else:
        ax = args[0]
    ...

would be more clear with

def delaxes(ax=None):
    """..."""
    if ax is None:
        ax = gca()
    ...

For all intended uses, the API compatibility is preserved. Unreasonable and possibly wrong uses like
delaxes(ax1, ax2) or delaxes(ax, mykwarg=True) would raise an Exception after the change. In itself, this is a benefit, because these cases will then be detected as false usage. However it may break existing programs.

Before I do any pull requests, is there a policy how to handle such cases?

  • Do you want to change these things, or should they be left as they are:
    • for cases like the above one where arguments are directly resolved in the function/method?
    • for cases where the all the arguments are passed like e.g. pyplot.savefig?
  • Which branch should changes go into?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy