From 90ce0841441506e3f409ab59ded1df8f2e6e7363 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Thu, 10 Aug 2023 21:19:29 -0400 Subject: treewide: automatic rewriting of all comment-style type annotations Performed using https://github.com/ilevkivskyi/com2ann This has no actual effect on the codebase as type checkers (still) support both and negligible effect on runtime performance since __future__ annotations ameliorates that. Technically, the bytecode would be bigger for non function-local annotations, of which we have many either way. So if it doesn't really matter, why do a large-scale refactor? Simple: because people keep wanting to, but it's getting nickle-and-dimed. If we're going to do this we might as well do it consistently in one shot, using tooling that guarantees repeatability and correctness. Repeat with: ``` com2ann mesonbuild/ ``` --- mesonbuild/mlog.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'mesonbuild/mlog.py') diff --git a/mesonbuild/mlog.py b/mesonbuild/mlog.py index e51399b4f..0e62a57d4 100644 --- a/mesonbuild/mlog.py +++ b/mesonbuild/mlog.py @@ -60,7 +60,7 @@ def _windows_ansi() -> bool: return bool(kernel.SetConsoleMode(stdout, mode.value | 0x4) or os.environ.get('ANSICON')) def colorize_console() -> bool: - _colorize_console = getattr(sys.stdout, 'colorize_console', None) # type: bool + _colorize_console: bool = getattr(sys.stdout, 'colorize_console', None) if _colorize_console is not None: return _colorize_console @@ -201,7 +201,7 @@ class _Logger: self.log_fatal_warnings = fatal_warnings def process_markup(self, args: T.Sequence[TV_Loggable], keep: bool, display_timestamp: bool = True) -> T.List[str]: - arr = [] # type: T.List[str] + arr: T.List[str] = [] if self.log_timestamp_start is not None and display_timestamp: arr = ['[{:.3f}]'.format(time.monotonic() - self.log_timestamp_start)] for arg in args: @@ -312,7 +312,7 @@ class _Logger: # The typing requirements here are non-obvious. Lists are invariant, # therefore T.List[A] and T.List[T.Union[A, B]] are not able to be joined if severity is _Severity.NOTICE: - label = [bold('NOTICE:')] # type: TV_LoggableList + label: TV_LoggableList = [bold('NOTICE:')] elif severity is _Severity.WARNING: label = [yellow('WARNING:')] elif severity is _Severity.ERROR: @@ -373,7 +373,7 @@ class _Logger: if prefix is None: prefix = red('ERROR:') self.log() - args = [] # type: T.List[T.Union[AnsiDecorator, str]] + args: T.List[T.Union[AnsiDecorator, str]] = [] if all(getattr(e, a, None) is not None for a in ['file', 'lineno', 'colno']): # Mypy doesn't follow hasattr, and it's pretty easy to visually inspect # that this is correct, so we'll just ignore it. -- cgit v1.2.3