Skip to content

Conversation

@flying-sheep
Copy link
Member

@flying-sheep flying-sheep commented Feb 26, 2024

The “only” problem is that this isn’t actually supported: python/mypy#14832, https://discuss.python.org/t/type-hints-for-kwarg-overrides/47196

If it was, it would have the advantage that we wouldn’t have to manually write overloads for each individual function.

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@flying-sheep flying-sheep requested a review from grst February 26, 2024 14:03
@flying-sheep flying-sheep changed the title Helper prototypes Decorator helper Feb 27, 2024
@grst
Copy link
Collaborator

grst commented Mar 3, 2024

Looks neat! Would it still work to plot into a single panel of an existing figure?

e.g.

fig, (ax1, ax2) = plt.subplots(2,1)
plot_umap(adata, ax=ax2)

@flying-sheep
Copy link
Member Author

flying-sheep commented Mar 4, 2024

The API is unchanged from main. You decorate a function taking fig and gs, and it makes it into a function having ax instead of these two.

As said, the only problem is that Python’s typing doesn‘t actually support modifying kwargs, so as neat as this would be, without a PEP to change this, we’ll have to go the more complicated route.

Or have the function have ax as first argument, which seems cumbersome.

See https://discuss.python.org/t/type-hints-for-kwarg-overrides/47196/7

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.

3 participants