#12784·wandb

[Bug]: RunEvent: allow omitted alternatives in metric-change overloads

Author: humdrum00001010Created Sep 10, 2026Updated Sep 15, 2026

Describe the bug

The overloads for RunEvent.metric(...).changes_by, increases_by, and decreases_by require both diff and frac arguments. Their implementations default each argument to None and require exactly one numerical threshold. Consequently, ordinary supported calls succeed at runtime but mypy rejects them.

This remains in main: overloads and implementation. The same one-argument calls are already exercised in upstream unit tests.

Minimal reproduction

Save as repro.py:

python
from wandb.automations import RunEvent

metric = RunEvent.metric("loss")
metric.changes_by(diff=1.0)
metric.changes_by(frac=0.1)
metric.increases_by(diff=1.0)
metric.increases_by(frac=0.1)
metric.decreases_by(diff=1.0)
metric.decreases_by(frac=0.1)

python repro.py succeeds. Each call returns a MetricChangeFilter. python -m mypy --follow-imports=silent --no-incremental repro.py reports six call-overload errors, for example:

error: No overload variant of "changes_by" of "BaseMetricOperand" matches argument type "float" [call-overload]
note: Possible overload variants:
note:     def changes_by(self, *, diff: int | float, frac: None) -> MetricChangeFilter
note:     def changes_by(self, *, diff: None, frac: int | float) -> MetricChangeFilter

No automation is created and no W&B login or server connection is needed.

Expected behavior

Have the public overloads accept the existing one-threshold calling forms while retaining the mutual-exclusion requirement.

Environment

  • W&B SDK: 0.30.0; runtime also checked on main 8f93d444e29e4d1a50a888899f51051012ee2679, whose overloads are unchanged
  • Python: 3.12.12
  • mypy: 2.3.1
  • OS: macOS 26.1, arm64
  • W&B server: not applicable