Skip to content

Modernize type hints in metric_group.py to Python 3.10+ syntax#3496

Merged
vfdev-5 merged 3 commits intomasterfrom
copilot/replace-typing-hints-in-file
Jan 19, 2026
Merged

Modernize type hints in metric_group.py to Python 3.10+ syntax#3496
vfdev-5 merged 3 commits intomasterfrom
copilot/replace-typing-hints-in-file

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 19, 2026

Replace deprecated typing generics with built-in types per Python 3.10+ standards.

Changes

  • Tuple[str, ...]tuple[str, ...]
  • Dict[str, Metric]dict[str, Metric]
  • Dict[str, Any]dict[str, Any]
  • Removed Tuple and Dict from typing imports
# Before
from typing import Any, Callable, Dict, Sequence, Tuple

def compute(self) -> Dict[str, Any]:
    ...

# After  
from typing import Any, Callable, Sequence

def compute(self) -> dict[str, Any]:
    ...
Original prompt

This section details on the original issue you should resolve

<issue_title>Replace typing hints with new version</issue_title>
<issue_description>Typing improvements we can make the change: Optional[Union[int, float]] = None into int | float = None which should be OK starting from python 3.10

We should replace all:

  • Union[A, B] with A | B
  • Optional[A] with A | None
  • Tuple -> tuple, List -> list, etc
    in the function signature and also of the output type hint

python 3.9 is EOL, min supported python version is 3.10.

It is a large issue, multiple people can work on it.
If you plan to work on it. Make changes in a single file and submit a PR. Smaller PR == easy review == quicker merging.
</issue_description>

<agent_instructions>Make sure to send one PR per one changed file. Start with files from ignite/tree/master/ignite/metrics folder.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@vfdev-5 It is a large issue, multiple people can work on it. I wont assign anyone on it. @vfdev-5 I updated the description, we should just replace all old type hints with the new one: Optional and Union in this issue.

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Replace typing hints with new version for improved compatibility Modernize type hints in metric_group.py to Python 3.10+ syntax Jan 19, 2026
Copilot AI requested a review from vfdev-5 January 19, 2026 10:41
@github-actions github-actions bot added the module: metrics Metrics module label Jan 19, 2026
@vfdev-5 vfdev-5 marked this pull request as ready for review January 19, 2026 11:19
@vfdev-5 vfdev-5 enabled auto-merge January 19, 2026 11:20
@vfdev-5 vfdev-5 added this pull request to the merge queue Jan 19, 2026
Merged via the queue into master with commit bc65b6a Jan 19, 2026
26 checks passed
@vfdev-5 vfdev-5 deleted the copilot/replace-typing-hints-in-file branch January 19, 2026 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module: metrics Metrics module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants