ui: split the `default` arg out of **kwargs for the internal prompt method
authorMatt Harbison <matt_harbison@yahoo.com>
Mon, 12 Dec 2022 14:17:05 -0500
changeset 49798 a51328ba33ca
parent 49797 0449fb7729d7
child 49799 de284a0b5614
ui: split the `default` arg out of **kwargs for the internal prompt method This arg was required anyway, based on how it was accessed. Having it separate allows it to be typed though, and this will simplify things for the callers- if a non-None `default` is passed, the return can never be None. That can be expressed with `@overload` when the arg can be typed, but that's not possible when it is rolled up in **kwargs. The default value is simply copied from the public `prompt()` above it.
mercurial/ui.py
--- a/mercurial/ui.py	Sun Dec 11 00:10:56 2022 -0500
+++ b/mercurial/ui.py	Mon Dec 12 14:17:05 2022 -0500
@@ -1786,8 +1786,8 @@
         """
         return self._prompt(msg, default=default)
 
-    def _prompt(self, msg, **opts):
-        default = opts['default']
+    def _prompt(self, msg, default=b'y', **opts):
+        opts = {**opts, 'default': default}
         if not self.interactive():
             self._writemsg(self._fmsgout, msg, b' ', type=b'prompt', **opts)
             self._writemsg(