##// END OF EJS Templates
typing: add type hints related to progress bars in mercurial/ui.py...
Matt Harbison -
r50689:25fe689a default
parent child Browse files
Show More
@@ -19,6 +19,10 b' import subprocess'
19 import sys
19 import sys
20 import traceback
20 import traceback
21
21
22 from typing import (
23 Optional,
24 )
25
22 from .i18n import _
26 from .i18n import _
23 from .node import hex
27 from .node import hex
24 from .pycompat import (
28 from .pycompat import (
@@ -2057,7 +2061,7 b' class ui:'
2057 )
2061 )
2058
2062
2059 @util.propertycache
2063 @util.propertycache
2060 def _progbar(self):
2064 def _progbar(self) -> Optional[progress.progbar]:
2061 """setup the progbar singleton to the ui object"""
2065 """setup the progbar singleton to the ui object"""
2062 if (
2066 if (
2063 self.quiet
2067 self.quiet
@@ -2068,14 +2072,16 b' class ui:'
2068 return None
2072 return None
2069 return getprogbar(self)
2073 return getprogbar(self)
2070
2074
2071 def _progclear(self):
2075 def _progclear(self) -> None:
2072 """clear progress bar output if any. use it before any output"""
2076 """clear progress bar output if any. use it before any output"""
2073 if not haveprogbar(): # nothing loaded yet
2077 if not haveprogbar(): # nothing loaded yet
2074 return
2078 return
2075 if self._progbar is not None and self._progbar.printed:
2079 if self._progbar is not None and self._progbar.printed:
2076 self._progbar.clear()
2080 self._progbar.clear()
2077
2081
2078 def makeprogress(self, topic, unit=b"", total=None):
2082 def makeprogress(
2083 self, topic: bytes, unit: bytes = b"", total: Optional[int] = None
2084 ) -> scmutil.progress:
2079 """Create a progress helper for the specified topic"""
2085 """Create a progress helper for the specified topic"""
2080 if getattr(self._fmsgerr, 'structured', False):
2086 if getattr(self._fmsgerr, 'structured', False):
2081 # channel for machine-readable output with metadata, just send
2087 # channel for machine-readable output with metadata, just send
@@ -2249,10 +2255,10 b' class ui:'
2249
2255
2250 # we instantiate one globally shared progress bar to avoid
2256 # we instantiate one globally shared progress bar to avoid
2251 # competing progress bars when multiple UI objects get created
2257 # competing progress bars when multiple UI objects get created
2252 _progresssingleton = None
2258 _progresssingleton: Optional[progress.progbar] = None
2253
2259
2254
2260
2255 def getprogbar(ui):
2261 def getprogbar(ui: ui) -> progress.progbar:
2256 global _progresssingleton
2262 global _progresssingleton
2257 if _progresssingleton is None:
2263 if _progresssingleton is None:
2258 # passing 'ui' object to the singleton is fishy,
2264 # passing 'ui' object to the singleton is fishy,
@@ -2261,7 +2267,7 b' def getprogbar(ui):'
2261 return _progresssingleton
2267 return _progresssingleton
2262
2268
2263
2269
2264 def haveprogbar():
2270 def haveprogbar() -> bool:
2265 return _progresssingleton is not None
2271 return _progresssingleton is not None
2266
2272
2267
2273
General Comments 0
You need to be logged in to leave comments. Login now