Skip to content
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

Skip the docstrings for functions pulled from cloned modules #1024

Merged
merged 3 commits into from
Aug 14, 2023
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
18 changes: 15 additions & 3 deletions cunumeric/coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import warnings
from dataclasses import dataclass
from functools import wraps
from functools import WRAPPER_ASSIGNMENTS, wraps
from types import (
BuiltinFunctionType,
FunctionType,
Expand Down Expand Up @@ -137,6 +137,11 @@ def wrapper(*args: Any, **kwargs: Any) -> Any:
return wrapper


_UNIMPLEMENTED_COPIED_ATTRS = tuple(
attr for attr in WRAPPER_ASSIGNMENTS if attr != "__doc__"
)


def unimplemented(
func: AnyCallable,
prefix: str,
Expand All @@ -157,7 +162,7 @@ def unimplemented(

if reporting:

@wraps(func)
@wraps(func, assigned=_UNIMPLEMENTED_COPIED_ATTRS)
bryevdv marked this conversation as resolved.
Show resolved Hide resolved
def wrapper(*args: Any, **kwargs: Any) -> Any:
location = find_last_user_frames(
not settings.report_dump_callstack()
Expand All @@ -174,7 +179,7 @@ def wrapper(*args: Any, **kwargs: Any) -> Any:

else:

@wraps(func)
@wraps(func, assigned=_UNIMPLEMENTED_COPIED_ATTRS)
def wrapper(*args: Any, **kwargs: Any) -> Any:
stacklevel = find_last_user_stacklevel()
warnings.warn(
Expand All @@ -187,6 +192,13 @@ def wrapper(*args: Any, **kwargs: Any) -> Any:
kwargs = deep_apply(kwargs, fallback)
return func(*args, **kwargs)

wrapper.__doc__ = f"""
cuNumeric has not implemented this function, and will fall back to NumPy.

See Also
--------
{name}
"""
wrapper._cunumeric = CuWrapperMetadata(implemented=False)

return wrapper
Expand Down
12 changes: 8 additions & 4 deletions tests/unit/cunumeric/test_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ def test_reporting_True_func(

assert wrapped.__name__ == _test_func.__name__
assert wrapped.__qualname__ == _test_func.__qualname__
assert wrapped.__doc__ == _test_func.__doc__
assert wrapped.__doc__ != _test_func.__doc__
assert "not implemented" in wrapped.__doc__
assert wrapped.__wrapped__ is _test_func

assert wrapped(10, 20) == 30
Expand All @@ -234,7 +235,8 @@ def test_reporting_False_func(

assert wrapped.__name__ == _test_func.__name__
assert wrapped.__qualname__ == _test_func.__qualname__
assert wrapped.__doc__ == _test_func.__doc__
assert wrapped.__doc__ != _test_func.__doc__
assert "not implemented" in wrapped.__doc__
assert wrapped.__wrapped__ is _test_func

with pytest.warns(RuntimeWarning) as record:
Expand All @@ -253,7 +255,8 @@ def test_reporting_True_ufunc(
) -> None:
wrapped = m.unimplemented(_test_ufunc, "foo", "_test_ufunc")

assert wrapped.__doc__ == _test_ufunc.__doc__
assert wrapped.__doc__ != _test_ufunc.__doc__
assert "not implemented" in wrapped.__doc__
assert wrapped.__wrapped__ is _test_ufunc

assert wrapped(10, 20) == 30
Expand All @@ -275,7 +278,8 @@ def test_reporting_False_ufunc(
_test_ufunc, "foo", "_test_ufunc", reporting=False
)

assert wrapped.__doc__ == _test_ufunc.__doc__
assert wrapped.__doc__ != _test_ufunc.__doc__
assert "not implemented" in wrapped.__doc__
assert wrapped.__wrapped__ is _test_ufunc

with pytest.warns(RuntimeWarning) as record:
Expand Down