Skip to content

✨ feat(discovery): add predicate parameter to get_interpreter#31

Merged
gaborbernat merged 1 commit intotox-dev:mainfrom
gaborbernat:30
Feb 26, 2026
Merged

✨ feat(discovery): add predicate parameter to get_interpreter#31
gaborbernat merged 1 commit intotox-dev:mainfrom
gaborbernat:30

Conversation

@gaborbernat
Copy link
Member

@gaborbernat gaborbernat commented Feb 26, 2026

Hatch monkeypatches propose_interpreters to filter out incompatible interpreters, which broke when virtualenv moved discovery into this package. There's currently no public API for downstream tools to reject interpreters that match a spec but fail some external constraint (e.g. platform compatibility). ✨ This adds a predicate callback to get_interpreter so tools like Hatch can filter without monkeypatching internals.

The predicate is evaluated after an interpreter satisfies the spec, giving callers a clean hook to accept or reject candidates while the discovery loop continues searching on rejection. Named predicate instead of filter to avoid shadowing the Python builtin (ruff A002 rule). The parameter defaults to None, so existing callers are unaffected.

📝 Sphinx docstrings were added to all public API methods and properties across ContentStore, PyInfoCache, DiskCache, PythonInfo, PythonSpec, and SimpleSpecifierSet. SimpleSpecifierSet is now also exported from the top-level package for downstream use.

Closes #30

@gaborbernat gaborbernat added the enhancement New feature or request label Feb 26, 2026
@gaborbernat gaborbernat enabled auto-merge (squash) February 26, 2026 09:24
Hatch monkeypatches `propose_interpreters` to filter out incompatible
interpreters, which broke when virtualenv moved discovery to this
package. Adding a `predicate` callback gives downstream tools a public
API to filter interpreters without monkeypatching internals.

Named `predicate` instead of `filter` to avoid shadowing the Python
builtin (ruff A002).

Closes tox-dev#30
@gaborbernat gaborbernat merged commit 20ba4bb into tox-dev:main Feb 26, 2026
13 checks passed
@gaborbernat gaborbernat deleted the 30 branch February 26, 2026 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Accomodate Hatch use case

1 participant