File tree Expand file tree Collapse file tree 2 files changed +29
-7
lines changed
Expand file tree Collapse file tree 2 files changed +29
-7
lines changed Original file line number Diff line number Diff line change 4343from tensorflow .python .framework import versions
4444from tensorflow .python .platform import tf_logging as logging
4545from tensorflow .python .util import compat
46- from tensorflow .python .util import deprecation
46+ from tensorflow .python .util import decorator_utils
4747
4848
4949def _override_helper (clazz_object , operator , func ):
@@ -3923,12 +3923,12 @@ class GraphKeys(object):
39233923 COND_CONTEXT = "cond_context"
39243924 WHILE_CONTEXT = "while_context"
39253925
3926- @property
3927- @ deprecation . deprecated ( "2017-03-02" ,
3928- "VARIABLES collection name is deprecated, "
3929- "please use GLOBAL_VARIABLES instead" )
3930- def VARIABLES ( self ):
3931- return self .GLOBAL_VARIABLES
3926+ @decorator_utils . classproperty
3927+ def VARIABLES ( cls ): # pylint: disable=no-self-argument
3928+ logging . warning ( "VARIABLES collection name is deprecated, "
3929+ "please use GLOBAL_VARIABLES instead; "
3930+ " VARIABLES will be removed after 2017-03-02." )
3931+ return cls .GLOBAL_VARIABLES
39323932
39333933
39343934def add_to_collection (name , value ):
Original file line number Diff line number Diff line change @@ -60,3 +60,25 @@ def validate_callable(func, decorator_name):
6060 ' @property appears before @%s in your source code:'
6161 '\n \n @property\n @%s\n def method(...)' % (
6262 func , decorator_name , decorator_name ))
63+
64+
65+ class classproperty (object ): # pylint: disable=invalid-name
66+ """Class property decorator.
67+
68+ Example usage:
69+
70+ class MyClass(object):
71+
72+ @classproperty
73+ def value(cls):
74+ return '123'
75+
76+ > print MyClass.value
77+ 123
78+ """
79+
80+ def __init__ (self , func ):
81+ self ._func = func
82+
83+ def __get__ (self , owner_self , owner_cls ):
84+ return self ._func (owner_cls )
You can’t perform that action at this time.
0 commit comments