Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Remove unused decorator_defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasdiez committed Nov 10, 2020
1 parent b414b8e commit dbe456a
Showing 1 changed file with 0 additions and 45 deletions.
45 changes: 0 additions & 45 deletions src/sage/misc/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,51 +159,6 @@ def _right(self, left):
return self.function(left, self.right)


@decorator
def decorator_defaults(func, *args, **kwds):
"""
This function allows a decorator to have default arguments.
Normally, a decorator can be called with or without arguments.
However, the two cases call for different types of return values.
If a decorator is called with no parentheses, it should be run
directly on the function. However, if a decorator is called with
parentheses (i.e., arguments), then it should return a function
that is then in turn called with the defined function as an
argument.
This decorator allows us to have these default arguments without
worrying about the return type.
EXAMPLES::
sage: from sage.misc.decorators import decorator_defaults
sage: @decorator_defaults
....: def my_decorator(f,*args,**kwds):
....: print(kwds)
....: print(args)
....: print(f.__name__)
sage: @my_decorator
....: def my_fun(a,b):
....: return a,b
{}
()
my_fun
sage: @my_decorator(3,4,c=1,d=2)
....: def my_fun(a,b):
....: return a,b
{'c': 1, 'd': 2}
(3, 4)
my_fun
"""
if len(kwds) == 0 and len(args) == 1:
# call without parentheses
return func(*args)
else:
return lambda f: func(f, *args, **kwds)


class suboptions(object):
def __init__(self, name, **options):
"""
Expand Down

0 comments on commit dbe456a

Please sign in to comment.