提交 bb1aede7 编写于 作者: Y Yifei Feng 提交者: GitHub

Merge pull request #6105 from gunan/cp

Revert "Removed unnecessary classproperty decorator"
...@@ -43,7 +43,7 @@ from tensorflow.python.framework import tensor_shape ...@@ -43,7 +43,7 @@ from tensorflow.python.framework import tensor_shape
from tensorflow.python.framework import versions from tensorflow.python.framework import versions
from tensorflow.python.platform import tf_logging as logging from tensorflow.python.platform import tf_logging as logging
from tensorflow.python.util import compat from tensorflow.python.util import compat
from tensorflow.python.util import deprecation from tensorflow.python.util import decorator_utils
def _override_helper(clazz_object, operator, func): def _override_helper(clazz_object, operator, func):
...@@ -3923,12 +3923,12 @@ class GraphKeys(object): ...@@ -3923,12 +3923,12 @@ class GraphKeys(object):
COND_CONTEXT = "cond_context" COND_CONTEXT = "cond_context"
WHILE_CONTEXT = "while_context" WHILE_CONTEXT = "while_context"
@property @decorator_utils.classproperty
@deprecation.deprecated("2017-03-02", def VARIABLES(cls): # pylint: disable=no-self-argument
"VARIABLES collection name is deprecated, " logging.warning("VARIABLES collection name is deprecated, "
"please use GLOBAL_VARIABLES instead") "please use GLOBAL_VARIABLES instead; "
def VARIABLES(self): "VARIABLES will be removed after 2017-03-02.")
return self.GLOBAL_VARIABLES return cls.GLOBAL_VARIABLES
def add_to_collection(name, value): def add_to_collection(name, value):
......
...@@ -60,3 +60,25 @@ def validate_callable(func, decorator_name): ...@@ -60,3 +60,25 @@ def validate_callable(func, decorator_name):
' @property appears before @%s in your source code:' ' @property appears before @%s in your source code:'
'\n\n@property\n@%s\ndef method(...)' % ( '\n\n@property\n@%s\ndef method(...)' % (
func, decorator_name, decorator_name)) func, decorator_name, decorator_name))
class classproperty(object): # pylint: disable=invalid-name
"""Class property decorator.
Example usage:
class MyClass(object):
@classproperty
def value(cls):
return '123'
> print MyClass.value
123
"""
def __init__(self, func):
self._func = func
def __get__(self, owner_self, owner_cls):
return self._func(owner_cls)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册