Skip to content

feat: Abstract out caching in discovery #2946

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

Merged
merged 6 commits into from
Aug 8, 2025

Conversation

esafak
Copy link
Contributor

@esafak esafak commented Aug 7, 2025

I refactored the code to abstract out caching through an interface. This change lays the groundwork for extracting discovery into its own package (#2074).

Here’s a summary of what I did:

  • I introduced a new Cache interface in src/virtualenv/discovery/cache.py.
  • I created a file-based implementation of this interface, FileCache, in src/virtualenv/discovery/file_cache.py.
  • I refactored the existing cached_py_info.py to use the Cache interface, decoupling it from the file-based implementation.
  • I updated py_info.py to work with the refactored cached_py_info.
  • ran the linter to address style issues (tox -e fix)
  • wrote descriptive pull request text
  • ensured there are test(s) validating the fix
  • added news fragment in docs/changelog folder
  • updated/extended the documentation

esafak added 4 commits August 6, 2025 22:18
I have refactored the code to abstract out caching through an interface. This change lays the groundwork for extracting discovery into its own package.

Here’s a summary of what I did:
- I introduced a new `Cache` interface in `src/virtualenv/discovery/cache.py`.
- I created a file-based implementation of this interface, `FileCache`, in `src/virtualenv/discovery/file_cache.py`.
- I refactored the existing `cached_py_info.py` to use the `Cache` interface, decoupling it from the file-based implementation.
- I updated `py_info.py` to work with the refactored `cached_py_info`.

Signed-off-by: Emre Şafak <[email protected]>
Signed-off-by: Emre Şafak <[email protected]>
Signed-off-by: Emre Şafak <[email protected]>
esafak added 2 commits August 7, 2025 17:44
* Add a docstring to the Cache ABC explaining the purpose of close() and __exit__ methods.
* Remove unused import from cached_py_info.py.

Signed-off-by: Emre Şafak <[email protected]>
@gaborbernat gaborbernat merged commit 78ebc61 into pypa:main Aug 8, 2025
42 checks passed
@esafak esafak deleted the feature/abstract-caching branch August 8, 2025 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants