-
-
Notifications
You must be signed in to change notification settings - Fork 654
Description
There are functions all over the library which accept various optional named parameters. Often the intention is that these will only be used as keyword parameters, but that fact is not enforced. Maintaining a huge number of possibly positional parameters can become a maintenance pain. (I'm currently seeing a mild version of this in #16533, but things could be much worse.)
PEP 3102 introduced syntax for this for Python 3.
This ticket introduces a decorator which will limit the number of positional parameters passed to its wrapped function.
-
To faciliate graceful deprecation, it might be associated with a trac ticket number and pass extra positional arguments after issuing a deprecation warning.
-
After the deprecation period, it would be replaced by proper keyword-only parameters.
Because of the performance penalty of the decorator, this should be done only for non-performance critical functions.
We demonstrate the use of the decorator on this ticket with a number of examples:
-
get_solver - this would catch the typical user error
get_solver('GLPK')
-
more TBD.
CC: @nilesjohnson @fchapoton @mwageringel
Component: misc
Author: Martin von Gagern
Branch/Commit: u/gagern/ticket/16607 @ 9755cda
Reviewer: Volker Braun
Issue created by migration from https://trac.sagemath.org/ticket/16607