#16607: Enforce keyword-only parameters
---------------------------+----------------------------
Reporter: gagern | Owner:
Type: enhancement | Status: new
Priority: major | Milestone: sage-6.3
Component: misc | Keywords:
Merged in: | Authors:
Reviewers: | Report Upstream: N/A
Work issues: | Branch:
Commit: | Dependencies:
Stopgaps: |
---------------------------+----------------------------
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 maintainance pain.
(I'm currently seeing a mild version of this in #16533, but things could
be ''much'' worse.)
While [http://legacy.python.org/dev/peps/pep-3102/ PEP 3102] introduced
syntax for this for Python 3, the most reasonable way to add such an
enforcement in Python 2 would be via a decorator. So I propose introducing
a decorator which will limit the number of positional parameters passed to
its wrapped function. To faciliate
[http://www.sagemath.org/doc/developer/coding_in_python.html#deprecation
graceful deprecation], it might be associated with a trac ticket number
and pass extra positional arguments after issuing a deprecation warning.
Once Sage moves to Python 3 (and I hope Sage will live long enough to make
that step unavoidable), we could probably refactor those into proper
keyword-only arguments, perhaps even automatically using some 2to3 plugin
if there is a sufficient number to warrant that effort.
--
Ticket URL: <http://trac.sagemath.org/ticket/16607>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.