##// END OF EJS Templates
handle multiple decorators in oinspect...
Min RK -
Show More
@@ -201,10 +201,7 b" def getsource(obj, oname=''):"
201 201 else:
202 202 # Get source for non-property objects.
203 203
204 # '__wrapped__' attribute is used by some decorators (e.g. ones defined
205 # functools) to provide access to the decorated function.
206 if hasattr(obj, "__wrapped__"):
207 obj = obj.__wrapped__
204 obj = _get_wrapped(obj)
208 205
209 206 try:
210 207 src = inspect.getsource(obj)
@@ -303,6 +300,12 b' def call_tip(oinfo, format_call=True):'
303 300 return call_line, doc
304 301
305 302
303 def _get_wrapped(obj):
304 """Get the original object if wrapped in one or more @decorators"""
305 while safe_hasattr(obj, '__wrapped__'):
306 obj = obj.__wrapped__
307 return obj
308
306 309 def find_file(obj):
307 310 """Find the absolute path to the file where an object was defined.
308 311
@@ -319,9 +322,7 b' def find_file(obj):'
319 322 fname : str
320 323 The absolute path to the file where the object was defined.
321 324 """
322 # get source if obj was decorated with @decorator
323 if safe_hasattr(obj, '__wrapped__'):
324 obj = obj.__wrapped__
325 obj = _get_wrapped(obj)
325 326
326 327 fname = None
327 328 try:
@@ -356,9 +357,7 b' def find_source_lines(obj):'
356 357 lineno : int
357 358 The line number where the object definition starts.
358 359 """
359 # get source if obj was decorated with @decorator
360 if safe_hasattr(obj, '__wrapped__'):
361 obj = obj.__wrapped__
360 obj = _get_wrapped(obj)
362 361
363 362 try:
364 363 try:
@@ -92,6 +92,8 b' def test_find_file_decorated2():'
92 92 return f(*a, **kw)
93 93
94 94 @noop2
95 @noop2
96 @noop2
95 97 def f(x):
96 98 "My docstring 2"
97 99
General Comments 0
You need to be logged in to leave comments. Login now