Repository navigation
Add py.typed marker to cosmology - #20568
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.
|
|
Just a note that we should double check that this actually works - I thought it could only be defined at a package level |
|
I agree this should be tested. https://peps.python.org/pep-0561/#packaging-type-information indicates that the PEP says it should work. But IDK what mypy does. |
|
Verified that astropy/cosmology/py.typed is included in the source distribution. I also built a minimal test package with a subpackage-level marker and confirmed that demo/cosmology/py.typed was included in its wheel. Tested mypy against the installed test package, but it inferred the same types after I removed the marker, so this test did not establish whether mypy's behavior depended on py.typed. I haven't verified whether Astropy's actual wheel includes the marker. My local wheel build failed because the required Microsoft Visual C++ build tools were unavailable. Is there a preferred test for verifying that mypy recognizes a py.typed marker placed inside a regular subpackage, such as astropy/cosmology/py.typed? |
|
@gitpsii do you use WSL2? You might be able to grab C lib stuff off conda that way, but it has been a while since I used it, so I am not 100% sure. |
|
Thanks for the suggestion! I currently don't have enough disk space to set up WSL2 and build Astropy in a Linux environment. I verified that astropy/cosmology/py.typed is included in the source distribution. I also built a minimal test package with a subpackage-level marker and confirmed that demo/cosmology/py.typed was included in its wheel. Would it be possible to verify the marker's inclusion in Astropy's wheel through an existing CI job, or is there a lighter-weight test you would recommend? |
nstarman
left a comment
There was a problem hiding this comment.
Given the PEP saying static type analyzers should support this and that it will be a long time (if ever) that Astropy ships this at the top level, I think this PR is worth it, even if mypy doesn't pick up on it.
|
On the topic of checking the wheels: we should configure our test Linux wheel job to upload the artifact to actions so people can download it and check in situations like this. |
|
@Cadair, a good idea! I opened an issue based on that comment. Feel free to edit it :) |
|
Thanks @gitpsii! |
|
Thanks for the review and for opening the follow-up issue! I appreciate the guidance. I'm glad this also highlighted a way to make wheel inspection easier for future contributors. |
Description
This pull request adds the py.typed marker file to astropy.cosmology, marking the subpackage as typed for static type checkers.
Fixes #20555
AI Disclosure
"N/A".
Merge method