-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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 pandas-stubs to typing dependencies #15849
base: main
Are you sure you want to change the base?
Conversation
Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.
|
👋 Thank you for your draft pull request! Do you know that you can use |
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.
Looks good to me. I was not familiar with pandas-stubs
but I looked into it and it seems like a good thing.
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.
If we have a typing
set of dependencies we might as well make use of it, but if we want to have more stubs than just pandas
then I don't see why we should open separate pull requests for all of them.
@eerovaher - perfect is the enemy of good. The idea is making incremental improvements that we agree move the project forward and not stalling progress in the pursuit of perfection. |
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.
Am OK with doing this. But just so I understand the purpose of the typing
dependency: is the idea here that when one develops with type checks enabled, we want to have the typing information for all optional dependencies as well, so that one does not get spurious errors? Is there a situation where it would make sense to have separate typing selections for just the minimal and/or recommended packages?
Anyway, overall, this seems fine. On the number of PRs: I assume there are not that many packages that separate out their typing entirely, so it seems fine to me to add those as they are encountered going through various astropy pieces.
Yes. Add as we encounter.
Yes. The best solution would be to somehow automate the discovery and installation of stubs without having to manually specify. This might be possible if we commit to a specific type checker and incorporate it into our CI. e.g. mypy has
IDK. Certainly worth considering. Given the non-runtime nature of the dependencies I think we can safely punt those details for now. |
I think it is. I think this stub is not compatible with oldest numpy we support? |
Thanks at @pllim for the diagnostic! |
WTF. Is there any version of pandas-stubs that works? |
Ok. Let's wait to add this until py3.10+. I'll move the dependency back to |
Moving this back to draft then. Thanks for trying! |
7d46e72
to
45b46d1
Compare
Signed-off-by: nstarman <nstarman@users.noreply.github.com>
45b46d1
to
f73b0f2
Compare
pyproject.toml
Outdated
@@ -69,7 +69,8 @@ recommended = [ | |||
"matplotlib>=3.3,!=3.4.0,!=3.5.2", | |||
] | |||
typing = [ | |||
"typing_extensions>=4.0.0" | |||
"typing_extensions>=4.0.0", | |||
"pandas-stubs>=1.4", |
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 is adding a version requirement to pandas-stubs
, but we don't have a version requirement for pandas
itself:
Line 84 in 769ad41
"pandas", |
Should we set a minimum supported version for pandas
too and am I right in guessing that the pandas-stubs
version matches the pandas
version it is providing the stubs for?
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.
We should probably actually limit our support of Pandas to >2? https://pypi.org/project/pandas/
@pllim, what do you think?
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.
According to the chart in https://scientific-python.org/specs/spec-0000/ , we still should support 1.5.0 until end of 2024?
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.
Oof. Ok! Then I can push a different PR for min pandas version.
We have pandas as an optional dependency. This PR ensures type checkers understand Pandas + Astropy.
All the contents of
typing
are NOT runtime dependencies. The only cost this dependency incurs is when installing withastropy[all]
, which picks up on all dependencies, not just runtime ones. Since we have Pandas already and this stubs package is maintained by Pandas, this is a very safe type-checking dependency to add.Found when testing #15794.
If you run
mypy
then it notices that there are a number of missing stubs dependencies. I think that we should at minimum have type-check level dependencies for our runtime packages (followup PR fortypes-PyYAML
) but also for important optional dependencies. Chances are good that users who care about typing will have these stubs installed already (using e.g.mypy --install-types
for automatic discovery) but it's good to be explicit.Requires #15603