diff options
author | Eli Schwartz <eschwartz@archlinux.org> | 2023-08-10 21:19:29 -0400 |
---|---|---|
committer | Eli Schwartz <eschwartz@archlinux.org> | 2023-08-11 13:41:03 -0400 |
commit | 90ce0841441506e3f409ab59ded1df8f2e6e7363 (patch) | |
tree | 3478769eef2620e9d7b5a41b73dd94c75b003465 /mesonbuild/mlog.py | |
parent | de1cc0b02bcb1bab6977f0ab8bb3fef0cd0646dd (diff) | |
download | meson-90ce0841441506e3f409ab59ded1df8f2e6e7363.zip meson-90ce0841441506e3f409ab59ded1df8f2e6e7363.tar.gz meson-90ce0841441506e3f409ab59ded1df8f2e6e7363.tar.bz2 |
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/
```
Diffstat (limited to 'mesonbuild/mlog.py')
-rw-r--r-- | mesonbuild/mlog.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/mesonbuild/mlog.py b/mesonbuild/mlog.py index e51399b..0e62a57 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. |