Skip to content

DOC: Fixes absent line numbers on link to classes decorated with set_module #28918

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,14 +539,14 @@ def linkcode_resolve(domain, info):
fn = None
lineno = None

# Make a poor effort at linking C extension types
if isinstance(obj, type) and obj.__module__ == 'numpy':
fn = _get_c_source_file(obj)
if isinstance(obj, type):
# Make a poor effort at linking C extension types
if obj.__module__ == 'numpy':
fn = _get_c_source_file(obj)

# This can be removed when removing the decorator set_module. Fix issue #28629
if hasattr(obj, '_module_file'):
fn = obj._module_file
fn = relpath(fn, start=dirname(numpy.__file__))
# This can be removed when removing the decorator set_module. Fix issue #28629
if hasattr(obj, '_module_source'):
obj.__module__, obj._module_source = obj._module_source, obj.__module__

if fn is None:
try:
Expand All @@ -573,6 +573,9 @@ def linkcode_resolve(domain, info):
else:
linespec = ""

if isinstance(obj, type) and hasattr(obj, '_module_source'):
obj.__module__, obj._module_source = obj._module_source, obj.__module__

if 'dev' in numpy.__version__:
return f"https://github.com/numpy/numpy/blob/main/numpy/{fn}{linespec}"
else:
Expand Down
5 changes: 2 additions & 3 deletions numpy/_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"""

import functools
import sys
import warnings
from ._convertions import asunicode, asbytes

Expand All @@ -29,8 +28,8 @@ def decorator(func):
if module is not None:
if isinstance(func, type):
try:
func._module_file = sys.modules.get(func.__module__).__file__
except (AttributeError, KeyError):
func._module_source = func.__module__
except (AttributeError):
pass

func.__module__ = module
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy