Skip to content

replace typing hints in ignite/handlers/tqdm_logger.py#3591

Merged
vfdev-5 merged 5 commits into
pytorch:masterfrom
roli-lpci:fix/typing-modernize
Feb 28, 2026
Merged

replace typing hints in ignite/handlers/tqdm_logger.py#3591
vfdev-5 merged 5 commits into
pytorch:masterfrom
roli-lpci:fix/typing-modernize

Conversation

@roli-lpci

Copy link
Copy Markdown
Contributor

Refs #3481

Description: Replace old typing hints with Python 3.10+ syntax in ignite/handlers/tqdm_logger.py.

  • Union[A, B] -> A | B
  • Optional[A] -> A | None
  • List -> list
  • Added from __future__ import annotations
  • Removed unused typing imports (List, Optional, Union)

Check list:

  • New tests are added (if a new feature is added)
  • New doc strings: description and/or example code are in RST format
  • Documentation is updated (if required)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions github-actions Bot added the module: handlers Core Handlers module label Feb 25, 2026
Comment thread ignite/handlers/tqdm_logger.py Outdated
omkar-334
omkar-334 previously requested changes Feb 25, 2026
Comment thread ignite/handlers/tqdm_logger.py Outdated
roli-lpci and others added 2 commits February 25, 2026 04:39
ignite requires Python >=3.10, so `X | Y` union syntax
works natively without the future import.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@roli-lpci

Copy link
Copy Markdown
Contributor Author

Thanks for the review! Removed the unnecessary __future__ import and the extra blank line.

Comment thread ignite/handlers/tqdm_logger.py Outdated
"""TQDM logger."""
from collections import OrderedDict
from typing import Any, Callable, List, Optional, Union
from typing import Any, Callable

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see in different PRs we have either from collections.abc import Callable, Mapping or from typing import Callable, Mapping. Let's make the code consistent and use from collections.abc import Callable, Mapping.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

@vfdev-5 vfdev-5 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@vfdev-5 vfdev-5 enabled auto-merge February 26, 2026 22:11
@vfdev-5 vfdev-5 dismissed omkar-334’s stale review February 26, 2026 22:11

Contributor addressed requested changes

@vfdev-5 vfdev-5 disabled auto-merge February 28, 2026 23:36
@vfdev-5 vfdev-5 merged commit dc7e856 into pytorch:master Feb 28, 2026
19 of 24 checks passed
vfdev-5 added a commit that referenced this pull request Feb 28, 2026
…#3596)

## Description
Modernize type hints in `ignite/handlers` core utility files by
replacing `typing` module imports (e.g., `Optional`, `Union`,
`Callable`, `Sequence`) with Python 3.10+ built-in syntax (`X | None`,
`list[...]`, `collections.abc`).
### Files changed:
- `ignite/handlers/__init__.py`
- `ignite/handlers/utils.py`
- `ignite/handlers/time_limit.py`
- `ignite/handlers/timing.py`
Related to #3591

---------

Co-authored-by: Manimaran <manimarantech@gmail.com>
Co-authored-by: vfdev <vfdev.5@gmail.com>
vfdev-5 added a commit that referenced this pull request Feb 28, 2026
#3597)

## Description
Modernize type hints in `ignite/handlers` scheduler and termination
files by replacing `typing` module imports with Python 3.10+ built-in
syntax.

### Files changed:
- `ignite/handlers/terminate_on_nan.py`
- `ignite/handlers/param_scheduler.py`
- `ignite/handlers/fbresearch_logger.py`

Related to #3591

---------

Co-authored-by: Manimaran <manimarantech@gmail.com>
Co-authored-by: vfdev <vfdev.5@gmail.com>
vfdev-5 pushed a commit that referenced this pull request Feb 28, 2026
## Description
Modernize type hints in `ignite/metrics/gan` submodule by replacing
`typing` module imports with Python 3.10+ built-in syntax.

### Files changed:
- `ignite/metrics/gan/fid.py`
- `ignite/metrics/gan/inception_score.py`
- `ignite/metrics/gan/utils.py`

Related to #3591

---------

Co-authored-by: Manimaran <manimarantech@gmail.com>
vfdev-5 added a commit that referenced this pull request Feb 28, 2026
…3604)

## Description
Modernize type hints in `ignite/metrics/clustering` submodule by
replacing `typing` module imports with Python 3.10+ built-in syntax and
`collections.abc`.

### Files changed:
- `ignite/metrics/clustering/_base.py`
- `ignite/metrics/clustering/silhouette_score.py`
- `ignite/metrics/clustering/davies_bouldin_score.py`
- `ignite/metrics/clustering/calinski_harabasz_score.py`

Related to #3591

---------

Co-authored-by: Manimaran <manimarantech@gmail.com>
Co-authored-by: vfdev <vfdev.5@gmail.com>
vfdev-5 added a commit that referenced this pull request Feb 28, 2026
…cs_lambda, precision, running_average, ssim) (#3602)

## Description
Modernize type hints in core `ignite/metrics` files (Part 2) by
replacing `typing` module imports with Python 3.10+ built-in syntax.

### Files changed:
- `ignite/metrics/metrics_lambda.py`
- `ignite/metrics/precision.py`
- `ignite/metrics/running_average.py`
- `ignite/metrics/ssim.py`

Related to #3591

---------

Co-authored-by: Manimaran <manimarantech@gmail.com>
Co-authored-by: vfdev <vfdev.5@gmail.com>
vfdev-5 added a commit that referenced this pull request Feb 28, 2026
## Description
Modernize type hints in `ignite/metrics/nlp` submodule by replacing
`typing` module imports with Python 3.10+ built-in syntax.

### Files changed:
- `ignite/metrics/nlp/bleu.py`
- `ignite/metrics/nlp/rouge.py`
- `ignite/metrics/nlp/utils.py`

Related to #3591

---------

Co-authored-by: Manimaran <manimarantech@gmail.com>
Co-authored-by: vfdev <vfdev.5@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module: handlers Core Handlers module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants