7from typing
import Any, Optional, TextIO, Type, Union
25 message: Union[Warning, str],
26 category: Type[Warning],
29 file: Optional[TextIO] =
None,
30 line: Optional[str] =
None,
33 if _original_showwarning
is not None:
34 _original_showwarning(message, category, filename, lineno, file, line)
35 elif issubclass(category, PipDeprecationWarning):
41 _original_showwarning(message, category, filename, lineno, file, line)
58 replacement: Optional[str],
59 gone_in: Optional[str],
60 feature_flag: Optional[str] =
None,
61 issue: Optional[int] =
None,
63 """Helper to deprecate existing functionality.
66 Textual reason shown to the user about why this functionality has
67 been deprecated. Should be a complete sentence.
69 Textual suggestion shown to the user about what alternative
70 functionality they can use.
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
76 Command-line flag of the form --use-feature={feature_flag} for testing
77 upcoming functionality.
79 Issue number on the tracker that would serve as a useful place for
80 users to find related discussion and provide feedback.
84 is_gone = gone_in
is not None and parse(current_version) >= parse(gone_in)
87 (reason, f
"{DEPRECATION_MSG_PREFIX}{{}}"),
90 "pip {} will enforce this behaviour change."
92 else "Since pip {}, this is no longer supported.",
96 "A possible replacement is {}.",
100 "You can use the flag --use-feature={} to test the upcoming behaviour."
106 "Discussion can be found at https://github.com/pypa/pip/issues/{}",
112 for value, format_str
in message_parts
113 if format_str
is not None and value
is not None
120 warnings.warn(message, category=PipDeprecationWarning, stacklevel=2)
None _showwarning(Union[Warning, str] message, Type[Warning] category, str filename, int lineno, Optional[TextIO] file=None, Optional[str] line=None)