|
2 | 2 | from __future__ import absolute_import, division, print_function
|
3 | 3 |
|
4 | 4 | import inspect
|
| 5 | +import warnings |
5 | 6 | from collections import namedtuple
|
6 | 7 | from operator import attrgetter
|
7 | 8 | from .compat import imap
|
| 9 | +from .deprecated import MARK_INFO_ATTRIBUTE |
8 | 10 |
|
| 11 | +def alias(name, warning=None): |
| 12 | + getter = attrgetter(name) |
9 | 13 |
|
10 |
| -def alias(name): |
11 |
| - # todo: introduce deprecationwarnings |
12 |
| - return property(attrgetter(name), doc='alias for ' + name) |
| 14 | + def warned(self): |
| 15 | + warnings.warn(warning, stacklevel=2) |
| 16 | + return getter(self) |
| 17 | + |
| 18 | + return property(getter if warning is None else warned, doc='alias for ' + name) |
13 | 19 |
|
14 | 20 |
|
15 | 21 | class ParameterSet(namedtuple('ParameterSet', 'values, marks, id')):
|
@@ -382,9 +388,9 @@ def __init__(self, mark):
|
382 | 388 | self.combined = mark
|
383 | 389 | self._marks = [mark]
|
384 | 390 |
|
385 |
| - name = alias('combined.name') |
386 |
| - args = alias('combined.args') |
387 |
| - kwargs = alias('combined.kwargs') |
| 391 | + name = alias('combined.name', warning=MARK_INFO_ATTRIBUTE) |
| 392 | + args = alias('combined.args', warning=MARK_INFO_ATTRIBUTE) |
| 393 | + kwargs = alias('combined.kwargs', warning=MARK_INFO_ATTRIBUTE) |
388 | 394 |
|
389 | 395 | def __repr__(self):
|
390 | 396 | return "<MarkInfo {0!r}>".format(self.combined)
|
|
0 commit comments