Skip to content

Commit b5e8495

Browse files
alfaro96adrinjalali
authored andcommitted
MNT Fix incorrect source code link for wrapped objects (scikit-learn#17247)
1 parent 26b5151 commit b5e8495

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

doc/sphinxext/github_link.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,13 @@ def _linkcode_resolve(domain, info, package, url_fmt, revision):
4040
return
4141

4242
class_name = info['fullname'].split('.')[0]
43-
if type(class_name) != str:
44-
# Python 2 only
45-
class_name = class_name.encode('utf-8')
4643
module = __import__(info['module'], fromlist=[class_name])
4744
obj = attrgetter(info['fullname'])(module)
4845

46+
# Unwrap the object to get the correct source
47+
# file in case that is wrapped by a decorator
48+
obj = inspect.unwrap(obj)
49+
4950
try:
5051
fn = inspect.getsourcefile(obj)
5152
except Exception:

0 commit comments

Comments
 (0)