summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPradyun Gedam <pradyunsg@gmail.com>2019-05-26 08:21:51 -0400
committerPradyun Gedam <pradyunsg@gmail.com>2019-05-27 13:57:38 -0400
commit2ff13e4340f263122d429dbf957297b64657222f (patch)
tree640cb2446e86ce94d3829c7a24226b13fe491287
parentbf728499beee85947d7c29a94ee8f4983d4a08a0 (diff)
downloadpip-2ff13e4340f263122d429dbf957297b64657222f.tar.gz
Use a loop instead of multiple similar conditionals
-rw-r--r--src/pip/_internal/utils/deprecation.py23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/pip/_internal/utils/deprecation.py b/src/pip/_internal/utils/deprecation.py
index ed07eb5f0..b9359bddc 100644
--- a/src/pip/_internal/utils/deprecation.py
+++ b/src/pip/_internal/utils/deprecation.py
@@ -80,17 +80,18 @@ def deprecated(reason, replacement, gone_in, issue=None):
# Construct a nice message.
# This is eagerly formatted as we want it to get logged as if someone
# typed this entire message out.
- message = DEPRECATION_MSG_PREFIX + reason
-
- if gone_in is not None:
- message += (
- " pip {} will remove support for this functionality".format(gone_in)
- )
- if replacement is not None:
- message += " A possible replacement is {}.".format(replacement)
- if issue is not None:
- url = "https://github.com/pypa/pip/issues/" + str(issue)
- message += " You can find discussion regarding this at {}.".format(url)
+ sentences = [
+ (reason, DEPRECATION_MSG_PREFIX + "{}"),
+ (gone_in, "pip {} will remove support for this functionality."),
+ (replacement, "A possible replacement is {}."),
+ (issue, (
+ "You can find discussion regarding this at "
+ "https://github.com/pypa/pip/issues/{}."
+ )),
+ ]
+ message = " ".join(
+ template.format(val) for val, template in sentences if val is not None
+ )
# Raise as an error if it has to be removed.
if gone_in is not None and parse(current_version) >= parse(gone_in):