From: David Riazati Date: Mon, 17 Dec 2018 22:38:46 +0000 (-0800) Subject: Don't enforce docstrings on bool dispatch (#15306) X-Git-Tag: accepted/tizen/6.5/unified/20211028.231830~2207 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=df4c9471eccb16f6f1c2966803d16f86187e9ed7;p=platform%2Fupstream%2Fpytorch.git Don't enforce docstrings on bool dispatch (#15306) Summary: Allows 2 functions that are boolean dispatched to have no docstrings (the only case that will fail now is if both functions have docstrings) Fixes #15281 Pull Request resolved: https://github.com/pytorch/pytorch/pull/15306 Differential Revision: D13494884 Pulled By: driazati fbshipit-source-id: 65fec39ae03a7d6a68ad617c9b270faeb1617930 --- diff --git a/torch/_jit_internal.py b/torch/_jit_internal.py index 18efc48..5594d41 100644 --- a/torch/_jit_internal.py +++ b/torch/_jit_internal.py @@ -137,6 +137,9 @@ def boolean_dispatch(arg_name, arg_index, default, if_true, if_false): elif if_false.__doc__ is None and if_true.__doc__ is not None: doc = if_true.__doc__ if_false.__doc__ = doc + elif if_false.__doc__ is None and if_true.__doc__ is None: + # neither function has a docstring + doc = None else: raise RuntimeError("only one function can have a docstring") fn.__doc__ = doc