Skip to content

Add missing step default to arange signature - #4855

Open
lipefree wants to merge 1 commit into
ml-explore:mainfrom
lipefree:fix/arange-step-default
Open

lipefree wants to merge 1 commit into
ml-explore:mainfrom
lipefree:fix/arange-step-default

Conversation

@lipefree

@lipefree lipefree commented Nov 9, 2026 •

Copy link
Copy Markdown

The signature for arange is defined with a default argument (nb::none()) for the argument step in the runtime binding (python/src/ops.cpp), but the explicit signature used to generate stubs uses step: None | int | float which causes type checkers like ty to raise the error No overload of function arange matches arguments in case we try to specify the arguments start and stop, omitting step.

import mlx.core as mx

# Error from `ty`: No overload of function `arange` matches arguments
x = mx.arange(start=1, stop=2)

# But this passes type checking in `ty`
x = mx.arange(start=1, stop=2, step=1)

We fix the stub definition by defining the function as

def arange(..., step : None | int | float = None, ...)

Validation by rebuilding the Python extension, regenerating stubs and running ty as a type checker on the modified definition.

  • ☑️ I understand it is strictly prohibited to use AI to write PR description
  • AI usage disclosure: co-developed with coding agent for finding the fix, building the projects and running the tests

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant