Repository navigation
Conversation
hashlib._Hash only existed in typeshed stubs and is not available at runtime, so sphinx-autodoc-typehints could not resolve the forward references and emitted warnings that fail the Read the Docs build. Annotate with _hashlib.HASH, imported under TYPE_CHECKING, instead. Also remove the ineffective autodoc_mock_imports entry for hashlib._Hash, as mocking only applies to modules, not attributes. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #760 +/- ##
==========================================
+ Coverage 93.90% 93.92% +0.02%
==========================================
Files 89 89
Lines 13924 13976 +52
==========================================
+ Hits 13075 13127 +52
Misses 849 849
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
djhoese
left a comment
There was a problem hiding this comment.
I could have sworn I fixed this already. Maybe it is in an unmerged PR or another package. The sphinx-autodoc-typehints package has seen a lot of changes around TYPE_CHECKING guards lately (see Satpy's previous documentation build failures) so I'm glad this works here now. The hashlib stuff...
Google says that hashlib._hashlib.HASH is the low level C object and should maybe be avoided for static type checking. The hashlib._Hash is the recommended way of doing this. Does moving the _Hash import into TYPE_CHECKING not work?
|
I really don't understand how typing should work, so lets go with trial and error. The Oh, but with this version the RtD build is failing again with the original error (warning): |
|
With new try also a failure: Running I'll go back to the first (wrong) iteration that Claude gave me and actually worked. |
|
So one thing is I think the "real" import is supposed to be The other thing is I don't think sphinx-autodoc-typehints handles imports the same way as type checkers necessarily. I've been doing a lot of bug reporting to sphinx-autodoc-typehints for the last couple versions so it may be worth asking Claude to try the last couple releases of that extension and seeing how it changes the different approaches here. It is possible a recent change broke this. |
|
Oh there have been a ton of releases of sphinx-autodoc-typehints in the last month. Sounds like this might be a bug report if it works in an older version. |
I saw RtD builds failing on #759 and asked Claude to check the failures. Here's the fix.
hashlib._Hash only existed in typeshed stubs and is not available at runtime, so sphinx-autodoc-typehints could not resolve the forward references and emitted warnings that fail the Read the Docs build. Annotate with _hashlib.HASH, imported under TYPE_CHECKING, instead.
Also remove the ineffective autodoc_mock_imports entry for hashlib._Hash, as mocking only applies to modules, not attributes.