-
-
Notifications
You must be signed in to change notification settings - Fork 144
GH1226 Add Styler.map to the stubs #1228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7a47b42
GH1226 Add Styler.map to the stubs
loicdiridollou a3357a3
Update pandas-stubs/io/formats/style.pyi
loicdiridollou 85eac7a
GH1226 PR Feedback
loicdiridollou 75b9ad9
GH1226 PR Feedback
loicdiridollou b7a991b
GH1226 PR Feedback
loicdiridollou 6dd566a
GH1226 PR Feedback
loicdiridollou 8196941
GH1226 PR Feedback
loicdiridollou File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Dr-Irv I could not find how to type a function that takes Scalar and some other stuff, I tried
[Scalar, ...]
but it was not happy, feel free to recommend something better.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is usually done using
Protocol
, I tried writing this:but it fails the test
Maybe this will be helpful to figure something out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea of using the
Protocol
works if we change the test. Instead ofif we use
then it is fine. Note that
pyright
accepts the func without the/
defined, butmypy
doesn't, so this is a workaround to makemypy
happy.@loicdiridollou change the test that way and put the
_MapCallable
near the otherProtocol
definition in that file and we should be good to go.@Molkree Thanks for the suggestion!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to double check that and I agree that this is mypy bug. According to these typing rules callable with standard argument of matching type should be assignable to the positional-only argument of matching type, same for kwargs but because we typed them as
Any
everything should be assignable to everything.I think it's this bug specifically: python/mypy#12525 (or a variation of it, error messages are not the same)
You learn something new everyday!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for all the feedback here, indeed I learn about those intricacies and mypy issues!
My only fear is that it would force people to have the argument-based function with the
/
, but I think it is worth trying out and seeing if we get complaints from the user base.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It only forces people who use
mypy
to include/
. If you usepyright
, it isn't required.