Open
Description
Bug summary
scale_factory requires Axis according to the type hints:
matplotlib/lib/matplotlib/scale.pyi
Line 177 in 8d64f03
But ax is even discouraged in the code:
matplotlib/lib/matplotlib/scale.py
Lines 51 to 63 in 8d64f03
matplotlib/lib/matplotlib/scale.pyi
Lines 8 to 9 in 8d64f03
Code for reproduction
from matplotlib.scale import scale_factory
scale_factory("linear", None)
# pyright:
# error: Argument of type "None" cannot be assigned to parameter "axis" of type "Axis" in function "scale_factory"
# "None" is not assignable to "Axis" (reportArgumentType)
# mypy:
# error: Argument 2 to "scale_factory" has incompatible type "None"; expected "Axis" [arg-type]
Actual outcome
# pyright:
# error: Argument of type "None" cannot be assigned to parameter "axis" of type "Axis" in function "scale_factory"
# "None" is not assignable to "Axis" (reportArgumentType)
# mypy:
# error: Argument 2 to "scale_factory" has incompatible type "None"; expected "Axis" [arg-type]
Expected outcome
mypy and pyright passing
Additional information
Using the same type hints as ScaleBase should solve this.
Operating system
No response
Matplotlib Version
3.9.2
Matplotlib Backend
No response
Python version
No response
Jupyter version
No response
Installation
None
Metadata
Metadata
Assignees
Labels
No labels