Skip to content

API: keywords only arguments #14714

@tupui

Description

@tupui

Is your feature request related to a problem? Please describe.

Keywords only arguments are arguably clearer and allow easier refactoring on our side. When adding a new feature, we are already thinking about using * to declare keyword only arguments.

Describe the solution you'd like.

scikit-learn already went through this process and with their v1 coming up, the whole code base is already keywords-only arguments. Hence, if accepted, I propose we follow the same path.

They did it in two phases:

  1. Deprecation phase with a wrapper: it takes a function and look at which arguments are keywords only. If you call the function using a positional argument instead of a keyword only argument (if f(a, *, b) and you do f(1, 2) instead of f(1, b=2)) then it will raise a deprecation warning. The function will still be working as the keyword arguments would not be enforced yet. The wrapper will convert the positional argument into a keyword argument.
  2. Remove the wrapper: after the deprecation cycle, remove the wrapper and we are done.

xref scikit-learn/scikit-learn#15005

Metadata

Metadata

Assignees

No one assigned

    Labels

    SciPEPSciPy Enhancement ProposaldeprecatedItems related to behavior that has been deprecated

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions