Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: third_party/logilab/common/deprecation.py

Issue 753543006: pylint: upgrade to 1.4.0 (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/logilab/common/dbf.py ('k') | third_party/logilab/common/optparser.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved. 1 # copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr 2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
3 # 3 #
4 # This file is part of logilab-common. 4 # This file is part of logilab-common.
5 # 5 #
6 # logilab-common is free software: you can redistribute it and/or modify it unde r 6 # logilab-common is free software: you can redistribute it and/or modify it unde r
7 # the terms of the GNU Lesser General Public License as published by the Free 7 # the terms of the GNU Lesser General Public License as published by the Free
8 # Software Foundation, either version 2.1 of the License, or (at your option) an y 8 # Software Foundation, either version 2.1 of the License, or (at your option) an y
9 # later version. 9 # later version.
10 # 10 #
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 def class_renamed(self, version, old_name, new_class, message=None): 118 def class_renamed(self, version, old_name, new_class, message=None):
119 clsdict = {} 119 clsdict = {}
120 if message is None: 120 if message is None:
121 message = '%s is deprecated, use %s' % (old_name, new_class.__name__ ) 121 message = '%s is deprecated, use %s' % (old_name, new_class.__name__ )
122 clsdict['__deprecation_warning__'] = message 122 clsdict['__deprecation_warning__'] = message
123 try: 123 try:
124 # new-style class 124 # new-style class
125 return self.class_deprecated(version)(old_name, (new_class,), clsdic t) 125 return self.class_deprecated(version)(old_name, (new_class,), clsdic t)
126 except (NameError, TypeError): 126 except (NameError, TypeError):
127 # old-style class 127 # old-style class
128 warn = self.warn
128 class DeprecatedClass(new_class): 129 class DeprecatedClass(new_class):
129 """FIXME: There might be a better way to handle old/new-style cl ass 130 """FIXME: There might be a better way to handle old/new-style cl ass
130 """ 131 """
131 def __init__(self, *args, **kwargs): 132 def __init__(self, *args, **kwargs):
132 self.warn(version, message, stacklevel=3) 133 warn(version, message, stacklevel=3)
133 new_class.__init__(self, *args, **kwargs) 134 new_class.__init__(self, *args, **kwargs)
134 return DeprecatedClass 135 return DeprecatedClass
135 136
136 def class_moved(self, version, new_class, old_name=None, message=None): 137 def class_moved(self, version, new_class, old_name=None, message=None):
137 """nice wrapper around class_renamed when a class has been moved into 138 """nice wrapper around class_renamed when a class has been moved into
138 another module 139 another module
139 """ 140 """
140 if old_name is None: 141 if old_name is None:
141 old_name = new_class.__name__ 142 old_name = new_class.__name__
142 if message is None: 143 if message is None:
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 sample.py:57: DeprecationWarning: Set is now replaced by set 180 sample.py:57: DeprecationWarning: Set is now replaced by set
180 s = Set() 181 s = Set()
181 >>> 182 >>>
182 """ 183 """
183 return _defaultdeprecator.class_renamed(None, old_name, new_class, message) 184 return _defaultdeprecator.class_renamed(None, old_name, new_class, message)
184 185
185 def class_moved(new_class, old_name=None, message=None): 186 def class_moved(new_class, old_name=None, message=None):
186 return _defaultdeprecator.class_moved(None, new_class, old_name, message) 187 return _defaultdeprecator.class_moved(None, new_class, old_name, message)
187 class_moved.__doc__ = _defaultdeprecator.class_moved.__doc__ 188 class_moved.__doc__ = _defaultdeprecator.class_moved.__doc__
188 189
OLDNEW
« no previous file with comments | « third_party/logilab/common/dbf.py ('k') | third_party/logilab/common/optparser.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698