ENH,BUG: Allow dict and callable "dispatch_args" specification #14
Merged
seberg merged 1 commit intoscientific-python:mainfrom Jul 6, 2025
Merged
ENH,BUG: Allow dict and callable "dispatch_args" specification #14seberg merged 1 commit intoscientific-python:mainfrom
seberg merged 1 commit intoscientific-python:mainfrom
Conversation
This was referenced Jul 5, 2025
f378456 to
012a976
Compare
This is a bit unwieldy. I had an old start where I used the signature (and some of the docs still said so), but that wasn't actually the case. This now properly documents the fact that a `dict` can be passed (which comes pretty directly from NetworkX). Unlike networkx, a single parameter is not assumed to be parameter 0 but instead, `inspect.signature` is used to figure this out. `dispatch_args` can now also be a callable, which is more clearly defined.
012a976 to
0fb04fb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Based on previous PR, thus draft.
This is a bit unwieldy. I had an old start where I used the signature (and some of the docs still said so), but that wasn't actually the case.
This now properly documents the fact that a
dictcan be passed (which comes pretty directly from NetworkX).Unlike networkx, a single parameter is not assumed to be parameter 0 but instead,
inspect.signatureis used to figure this out.dispatch_argscan now also be a callable, which is more clearly defined.I looked at this because I wanted to add the ability to use a callable, which I think is good. But... I am not sure about the other options we want to support here.
There was an old partial code where I wanted to use
signature.inspect, but we abandoned it while prototyping @eriknw.I am just not sure if that was just to get started, or whether we decided that it is being too smart? Maybe @Schefflera-Arboricola you have an opinion what to allow here?
(We can always allow more, e.g. I am considering using type annotations and
inspect.signatureto automatically find the right parameters from just a type.)(I also saw that NetworkX has a
?to denote optional. Which I think isn't relevant here, since it seems fine if it fails later.)