Make mypy opt-out instead of opt-in (#33205)

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
Harry Mellor
2026-01-29 09:12:26 +00:00
committed by GitHub
parent a650ad1588
commit fb946a7f89
11 changed files with 35 additions and 57 deletions

View File

@@ -4,6 +4,7 @@
import dataclasses
from collections.abc import Callable
from _typeshed import DataclassInstance
from torch._C._profiler import _EventType, _ProfilerEvent, _TensorMetadata
#
@@ -11,7 +12,7 @@ from torch._C._profiler import _EventType, _ProfilerEvent, _TensorMetadata
#
def trim_string_front(string, width):
def trim_string_front(string: str, width: int) -> str:
if len(string) > width:
offset = len(string) - width + 3
string = string[offset:]
@@ -20,7 +21,7 @@ def trim_string_front(string, width):
return string
def trim_string_back(string, width):
def trim_string_back(string: str, width: int) -> str:
if len(string) > width:
offset = len(string) - width + 3
string = string[:-offset]
@@ -30,15 +31,13 @@ def trim_string_back(string, width):
class TablePrinter:
def __init__(
self, row_cls: type[dataclasses.dataclass], column_widths: dict[str, int]
):
def __init__(self, row_cls: type[DataclassInstance], column_widths: dict[str, int]):
self.row_cls = row_cls
self.fieldnames = [x.name for x in dataclasses.fields(row_cls)]
self.column_widths = column_widths
assert set(self.column_widths.keys()) == set(self.fieldnames)
def print_table(self, rows: list[dataclasses.dataclass]):
def print_table(self, rows: list[DataclassInstance]):
self._print_header()
self._print_line()
for row in rows: