Summary
Applying PYI041 --fix will replace a numeric union annotation like int | float with float, but this is an incorrect fix for a method that is annotated with @func.register for a functools.singledispatch function.
Minimal example code:
import functools
@functools.singledispatch
def int_or_float(value: object) -> str:
return False
@int_or_float.register
def _(value: int | float):
return True
assert int_or_float(3)
Repro script:
repro-ruff-redundant-numeric-union-singledispatch.sh
Version
ruff 0.16.0 (did not check any other versions)
Summary
Applying PYI041 --fix will replace a numeric union annotation like
int | floatwithfloat, but this is an incorrect fix for a method that is annotated with@func.registerfor a functools.singledispatch function.Minimal example code:
Repro script:
repro-ruff-redundant-numeric-union-singledispatch.sh
Version
ruff 0.16.0 (did not check any other versions)