62) -> None:
63 """Helper to deprecate existing functionality.
64
65 reason:
66 Textual reason shown to the user about why this functionality has
67 been deprecated. Should be a complete sentence.
68 replacement:
69 Textual suggestion shown to the user about what alternative
70 functionality they can use.
71 gone_in:
72 The version of pip does this functionality should get removed in.
73 Raises an error if pip's current version is greater than or equal to
74 this.
75 feature_flag:
76 Command-line flag of the form --use-feature={feature_flag} for testing
77 upcoming functionality.
78 issue:
79 Issue number on the tracker that would serve as a useful place for
80 users to find related discussion and provide feedback.
81 """
82
83
84 is_gone = gone_in is not None and parse(current_version) >= parse(gone_in)
85
86 message_parts = [
87 (reason, f"{DEPRECATION_MSG_PREFIX}{{}}"),
88 (
89 gone_in,
90 "pip {} will enforce this behaviour change."
91 if not is_gone
92 else "Since pip {}, this is no longer supported.",
93 ),
94 (
95 replacement,
96 "A possible replacement is {}.",
97 ),
98 (
99 feature_flag,
100 "You can use the flag --use-feature={} to test the upcoming behaviour."
101 if not is_gone
102 else None,
103 ),
104 (
105 issue,
106 "Discussion can be found at https://github.com/pypa/pip/issues/{}",
107 ),
108 ]
109
110 message = " ".join(
112 for value, format_str in message_parts
113 if format_str is not None and value is not None
114 )
115
116
117 if is_gone:
118 raise PipDeprecationWarning(message)
119
120 warnings.warn(message, category=PipDeprecationWarning, stacklevel=2)