Skip to content

Commit 6556e16

Browse files
authored
Fixed mypy failures on the CI (#3296)
1 parent 8782ca4 commit 6556e16

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

ignite/handlers/time_profilers.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ def print_results(results: Dict) -> str:
400400
401401
"""
402402

403-
def to_str(v: Union[str, tuple]) -> str:
403+
def to_str(v: Union[str, tuple, int, float]) -> str:
404404
if isinstance(v, str):
405405
return v
406406
elif isinstance(v, tuple):
@@ -412,12 +412,14 @@ def odict_to_str(d: Mapping) -> str:
412412
return out
413413

414414
others = {
415-
k: odict_to_str(v) if isinstance(v, OrderedDict) else v for k, v in results["event_handlers_stats"].items()
415+
k: odict_to_str(v) if isinstance(v, OrderedDict) else to_str(v)
416+
for k, v in results["event_handlers_stats"].items()
416417
}
417418

418419
others.update(results["event_handlers_names"])
419420

420-
output_message = """
421+
output_message: str = (
422+
"""
421423
----------------------------------------------------
422424
| Time profiling stats (in seconds): |
423425
----------------------------------------------------
@@ -430,7 +432,7 @@ def odict_to_str(d: Mapping) -> str:
430432
{dataflow_stats}
431433
432434
Event handlers:
433-
{total_time:.5f}
435+
{total_time}
434436
435437
- Events.STARTED: {STARTED_names}
436438
{STARTED}
@@ -450,9 +452,10 @@ def odict_to_str(d: Mapping) -> str:
450452
- Events.COMPLETED: {COMPLETED_names}
451453
{COMPLETED}
452454
""".format(
453-
processing_stats=odict_to_str(results["processing_stats"]),
454-
dataflow_stats=odict_to_str(results["dataflow_stats"]),
455-
**others,
455+
processing_stats=odict_to_str(results["processing_stats"]),
456+
dataflow_stats=odict_to_str(results["dataflow_stats"]),
457+
**others,
458+
)
456459
)
457460
print(output_message)
458461
return output_message

ignite/metrics/fbeta.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def thresholded_output_transform(output):
151151

152152
if precision is None:
153153
precision = Precision(
154-
output_transform=(lambda x: x) if output_transform is None else output_transform, # type: ignore[arg-type]
154+
output_transform=(lambda x: x) if output_transform is None else output_transform,
155155
average=False,
156156
device=device,
157157
)
@@ -160,7 +160,7 @@ def thresholded_output_transform(output):
160160

161161
if recall is None:
162162
recall = Recall(
163-
output_transform=(lambda x: x) if output_transform is None else output_transform, # type: ignore[arg-type]
163+
output_transform=(lambda x: x) if output_transform is None else output_transform,
164164
average=False,
165165
device=device,
166166
)

0 commit comments

Comments
 (0)