Skip to content
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

intersphinx: Handle the case where intersphinx_cache_limit is negative #12514

Merged
merged 2 commits into from
Jul 31, 2024

Conversation

SilverRainZ
Copy link
Contributor

Subject: intersphinx: Handle the case where intersphinx_cache_limit is negative

Feature or Bugfix

  • Bugfix

Purpose

Ensuring the confval intersphinx_cache_limit behaves as documented.

Detail

The documentation said:

Set this to a negative value to cache inventories
for unlimited time.

In the current implementation, a negative intersphinx_cache_limit causes
inventories always expire, this patch ensures that it behaves as documented.

Relates

@SilverRainZ SilverRainZ force-pushed the intersphinx_cache_limit branch 3 times, most recently from 7d3dc64 to 535977e Compare July 7, 2024 14:00
Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add some tests for that as well?

By the way, I'm surprised no one ever complained...

CHANGES.rst Outdated Show resolved Hide resolved
sphinx/ext/intersphinx/_load.py Outdated Show resolved Hide resolved
sphinx/ext/intersphinx/_load.py Outdated Show resolved Hide resolved
@SilverRainZ SilverRainZ force-pushed the intersphinx_cache_limit branch 4 times, most recently from 847acac to cd7aa0a Compare July 10, 2024 06:12
@SilverRainZ
Copy link
Contributor Author

@picnixz I have added a test case, but only test the negative case, I am not sure how to test the positive one for it needs more mocked data.

@picnixz
Copy link
Member

picnixz commented Jul 13, 2024

I am not sure how to test the positive one for it needs more mocked data.

If I have time tomorrow (I've got some reviews to do + some stuff to complete on CPython), I'll make a PR on your forked branch (or just dump the code here). But I'm not sure I'll have time. Otherwise, I think it's fine. I just need to remember how I mocked my own tests for those kind of things...

@SilverRainZ SilverRainZ force-pushed the intersphinx_cache_limit branch 2 times, most recently from cc81306 to 4f44c8e Compare July 26, 2024 05:08
@SilverRainZ
Copy link
Contributor Author

rebased to master again.

The documentation said:

  Set this (intersphinx_cache_limit) to a negative value to cache inventories
  for unlimited time.

In the current implementation, a negative intersphinx_cache_limit causes
inventories always expire, this patch ensures that it behaves as documented.
@SilverRainZ
Copy link
Contributor Author

I can not run my test because of the following error:

\ $ python -m pytest -v tests/test_extensions/test_ext_intersphinx.py::test_intersphinx_cache_limit
ImportError while loading conftest '/Users/bytedance/git/public/sphinx-la/tests/conftest.py'.
tests/conftest.py:15: in <module>
    from sphinx.testing.util import _clean_up_global_state
sphinx/testing/util.py:17: in <module>
    import sphinx.application
sphinx/application.py:30: in <module>
    from sphinx.highlighting import lexer_classes
sphinx/highlighting.py:86: in <module>
    class PygmentsBridge:
sphinx/highlighting.py:89: in PygmentsBridge
    html_formatter = HtmlFormatter[str]
E   TypeError: type 'HtmlFormatter' is not subscriptable

@picnixz
Copy link
Member

picnixz commented Jul 26, 2024

You should update your version of pygments to include this commit: pygments/pygments@0f40614 (though it's weird because your PR is more recent ?)

@AA-Turner
Copy link
Member

I am not sure how to test the positive one for it needs more mocked data.

If I have time tomorrow (I've got some reviews to do + some stuff to complete on CPython), I'll make a PR on your forked branch (or just dump the code here). But I'm not sure I'll have time. Otherwise, I think it's fine. I just need to remember how I mocked my own tests for those kind of things...

@picnixz did you want to add these tests or are we OK to merge?

A

@picnixz
Copy link
Member

picnixz commented Jul 31, 2024

did you want to add these tests or are we OK to merge?

I shamefully forgot. I'm fine with your test (much smaller, less complicate).

@AA-Turner AA-Turner merged commit 03d684f into sphinx-doc:master Jul 31, 2024
19 checks passed
@AA-Turner
Copy link
Member

I shamefully forgot. I'm fine with your test (much smaller, less complicate).

There's no shame in being busy! Thanks for the quick reply

A

@AA-Turner AA-Turner added this to the 8.x milestone Jul 31, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants