Skip to content

Update type hints in accumulation.py to PEP 604 syntax#3518

Merged
vfdev-5 merged 4 commits intomasterfrom
copilot/update-typing-hints
Feb 6, 2026
Merged

Update type hints in accumulation.py to PEP 604 syntax#3518
vfdev-5 merged 4 commits intomasterfrom
copilot/update-typing-hints

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 6, 2026

Modernizes type hints in ignite/metrics/accumulation.py to use Python 3.10+ union syntax per issue #3481.

Changes

  • Union[A, B]A | B (11 instances)
  • Tuple[...]tuple[...] (1 instance)
  • Removed unused Union, Tuple imports

Example

# Before
def __init__(
    self,
    device: Union[str, torch.device] = torch.device("cpu"),
) -> None:
    ...

def compute(self) -> Union[float, torch.Tensor]:
    ...

# After  
def __init__(
    self,
    device: str | torch.device = torch.device("cpu"),
) -> None:
    ...

def compute(self) -> float | torch.Tensor:
    ...

Affects VariableAccumulation, Average, and GeometricAverage classes.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@vfdev-5 vfdev-5 marked this pull request as ready for review February 6, 2026 13:02
Copilot AI changed the title [WIP] Update old typing hints in ignite/metrics Update type hints in accumulation.py to PEP 604 syntax Feb 6, 2026
Copilot AI requested a review from vfdev-5 February 6, 2026 13:05
Copilot AI requested a review from vfdev-5 February 6, 2026 13:13
@github-actions github-actions bot added the module: metrics Metrics module label Feb 6, 2026
@vfdev-5 vfdev-5 enabled auto-merge February 6, 2026 13:42
@vfdev-5 vfdev-5 added this pull request to the merge queue Feb 6, 2026
Merged via the queue into master with commit 5b1da58 Feb 6, 2026
26 checks passed
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