theislab / scanpydoc

Collection of Sphinx extensions similar to (but more flexible than) numpydoc
https://icb-scanpydoc.readthedocs-hosted.com/en/latest/
GNU General Public License v3.0
12 stars 6 forks source link

scanpydoc.elegant_typehint breaks doc caching #51

Closed ivirshup closed 1 year ago

ivirshup commented 2 years ago

scanpydoc.elegant_typehint seems to be modifying the config after it's been loaded, making sphinx think it has changed. This causes full rebuilds every time, which is quite painful for minor changes. This is reported via:

updating environment: [config changed ('typehints_formatter')] 317 added, 0 changed, 0 removed

Because of this, I've disabled scanpydoc.elegant_typehint in scanpy (theislab/scanpy#2199).

I'm not entirely sure how to fix this. I hoped that just moving the assignment of typehints_formatter would have done the trick, but it does not.

flying-sheep commented 2 years ago

You already set typehints_defaults = 'braces', so what you describe doesn’t happen anymore. Fixed in https://github.com/scverse/scanpy/pull/2204

ivirshup commented 2 years ago

Checking it out locally, that PR causes the issue to come back. I think the typehints_formatter parameter causes the problem – though maybe typehints_default would too.

flying-sheep commented 2 years ago

Moving my comment from there here:

looks like a Sphinx bug, as even setting it manually doesn’t change things.

Maybe pickling the function leads to it having a different object id…

The only ways to fix this:

  1. set the value to a string like 'scanpydoc.elegant_typehints:typehints_formatter' and implement importing that object in sphinx-autodoc-typehint
  2. make it so sphinx compares function-valued settings in a way that doesn’t bust the cache.

So not something fixable here per se

flying-sheep commented 1 year ago

I figured out a way, fixed in #79