ruff
107e38d0 - [ty] Introduce a semantic model for a pytest fixture binding (#27443)

Commit
94 days ago
[ty] Introduce a semantic model for a pytest fixture binding (#27443) <!-- Thank you for contributing to Ruff/ty! To help us out with reviewing, please consider the following: - Does this pull request include a summary of the change? (See below.) - Does this pull request include a descriptive title? (Please prefix with `[ty]` for ty pull requests.) - Does this pull request include references to any relevant issues? - Does this PR follow our AI policy (https://github.com/astral-sh/.github/blob/main/AI_POLICY.md)? --> ## Summary <!-- What's the purpose of the change? What does it do, and why? --> This introduces a semantic model for a pytest fixture binding: a connection between a test function parameter and a fixture function declaration. The model overlays ordinary Python name resolution which only sees the requesting parameter as a local definition, and does not connect it to the fixture declaration. For example: ```py import pytest @pytest.fixture(name="database") def make_database(): return object() def test_query(database): assert database is not None ``` Here, `make_database` is a fixture declaration, "database" is the name under which it is exposed, the `database` parameter on `test_query` is a fixture request, and our new model creates a binding which connects that request to the decorated function. I chose to scope this first pass down to just supporting just those bindings that occur when a fixture request and its corresponding fixture declaration occur in the same file. That scope is arbitrary, and is only intended to make this initial PR easier to review. Subsequent PRs will expand that scope and actually hook this up to the language server; for the moment this new model is unused and does not affect either type inference or language server behaviour. It will first be used to implement [go-to-definition for fixture requests](https://github.com/astral-sh/ruff/pull/27444). /xref https://github.com/astral-sh/ty/issues/4115 ## Test Plan See included tests. <!-- How was it tested? -->
Author
Parents
Loading