cosmo: add type annotations to astropy.cosmology.units.py (REVERTED)#15852
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 |
|
I'm debating whether to define a TypeAlias for DistanceKind: TypeAlias = Literal["comoving", "lookback", "luminosity"] |
astropy.cosmology.units.py
astropy.cosmology.units.pyastropy.cosmology.units.py
|
Sigh. RTD errors are the most annoying to resolve. Who the heck knows how it finds its reference targets. As a note, I'm pretty sure that if we adopt astropy/astropy-APEs#85 then we won't have this problem since I think RTD correctly recognizes |
|
I'm excited to see this PR!
Sigh, indeed. We added a fairly long section on how to deal with Reference target not found RTD errors to PlasmaPy's documentation guide. |
|
Thanks @namurphy. That's a useful guide! Unfortunately I don't think it covers this edge case (see sphinx-doc/sphinx#10400) |
|
937f0af shows that removing |
03afd4b to
a03ee30
Compare
|
Hopefully #15862 will fix this. Sphinx uses the PEP8 definitions of public API, which is how my type annotation tripped it up here. Sphinx also has a precedence criteria, so hopefully defining Update: unfortunately #15862 is not a fix. The precedence for |
a03ee30 to
7641207
Compare
|
Ping @mhvk. I'm trying to resolve an issue with RTD. Sphinx is trying to resolve the type annotations and finds |
29cf0bc to
a8bcaaa
Compare
|
One issue we had before with I suspect you are running into something similar. To test this, could you try removing I think even if it does not, since That said, there is something somewhat illogical more generally about showing API/contents for what nominally are private modules. If we could adjust |
|
@mhvk. That appears to work! Looks like we also need to remove |
dda0567 to
8fc6b4a
Compare
|
OK, great, that at least narrows it down. It sounds like something to raise over at sphinx (independently of whether we change our docs around ourselves). |
|
Given the addition of units.all, I don't think we're losing anything except logical groupings from the docs by removing these references. Should we merge this in and work on the docs in a separate PR? |
|
That seems the wrong order - let's separate out the removals to a new PR that also gets the docs OK again first. |
|
See #15891 |
c9497b3 to
4d26aa7
Compare
mhvk
left a comment
There was a problem hiding this comment.
Beyond those :noindex: additions, everything looks good...
|
Thanks @mhvk, @eerovaher, @eerovaher for the reviews! These RTD errors can be hard to diagnose and fix. |
4d26aa7 to
bfe48a8
Compare
Signed-off-by: nstarman <[email protected]>
bfe48a8 to
35da854
Compare
eerovaher
left a comment
There was a problem hiding this comment.
I think this is ready to be squashed and merged, but I'd prefer this to have more than one approval, so I'm not merging immediately.
neutrinoceros
left a comment
There was a problem hiding this comment.
I'm this close to approving.
| def redshift_distance(cosmology=None, kind="comoving", **atzkw): | ||
| def redshift_distance( | ||
| cosmology: Cosmology | str | None = None, | ||
| kind: Literal["comoving", "lookback", "luminosity"] = "comoving", |
There was a problem hiding this comment.
tangent, but I notice that the docstring doesn't say which option is the default, maybe now is as good a time as any to fix this.
There was a problem hiding this comment.
The first value listed in braces is the default and it does not need to be highlighted more than that: https://numpydoc.readthedocs.io/en/latest/format.html#parameters
There was a problem hiding this comment.
Today I learned. Thanks !
Co-authored-by: Clément Robert <[email protected]>
|
Thanks, @nstarman! |
|
Did this break RTD?
|
|
How weird!! |
|
I think this might just need another addition to nitpick-exceptions. We've had to clobber every problem with Sphinx by just ignoring it using this file. |
astropy.cosmology.units.pyastropy.cosmology.units.py (REVERTED)
When I add type hints to
cosmology.funcs.optimize.pythen I'll be able to add better hints to theatzkwarguments, but for now these generic annotations are good.Plz squash and cleanup merge message.