-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add seaborn stubs #10721
Add seaborn stubs #10721
Conversation
This comment has been minimized.
This comment has been minimized.
For the Line 152 in cecab9c
If need be, we could probably just add some hacky special-casing for pandas-stubs to the function, e.g. if req_name == "pandas-stubs":
return ["pandas"] |
The We may need to consider adding a |
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Thanks for looking into this. Should we open an issue about this to see what other maintainers say? |
Yes, that would be great! |
This comment has been minimized.
This comment has been minimized.
I've triggered a rerun of the stub-uploader tests now typeshed-internal/stub_uploader#102 has been merged. EDIT: They pass now; just |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
All green now 🥳 though I think we should also wait for typeshed-internal/stub_uploader#103 before we can consider merging this |
I'll mark the PR as "Ready for review" because it is ready for review :P. |
typeshed-internal/stub_uploader#103 was merged 🎉 |
It seems like seaborn has a lot of inline types, and these stubs closely track them. Have you considered asking whether they would ship a py.typed? I don't see any discussion of that in their issue tracker. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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 clarifying, indeed the files outside _core
are mostly not annotated. I reviewed up to cm.pyi
now, mostly by spot-checking and reading along with the implementation.
stubs/seaborn/seaborn/axisgrid.pyi
Outdated
*, | ||
hue: str | None = None, | ||
vars: Iterable[str] | None = None, | ||
x_vars: Iterable[str] | None = None, |
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.
This check seems to indicate a broader type:
if np.isscalar(x_vars):
x_vars = [x_vars]
(Same for y_vars)
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.
These are documented as "lists of variable names" but I annotated them as iterables because they are casted to list at runtime. The isscalar
check seems to allow str
to be accepted but this is already covered by Iterable[str]
. I think no change is needed here?
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.
Doesn't feel great to rely on the fact that str
is an Iterable[str]
, as usually that isn't what you want. As I recall pytype generally disallows str for Iterable[str]. So let's be explicit:
x_vars: Iterable[str] | None = None, | |
x_vars: Iterable[str] | str | None = None, |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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.
Got to the end this time! A few more comments.
This comment has been minimized.
This comment has been minimized.
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Thanks for your work @hamdanal! |
Requires