Skip to content

[ty] Factor function-level work out of pytest fixture request lookup - #28073

Merged
lerebear merged 1 commit into
mainfrom
lerebear/push-okknqpkrxrpv
Aug 26, 2026
Merged

[ty] Factor function-level work out of pytest fixture request lookup#28073
lerebear merged 1 commit into
mainfrom
lerebear/push-okknqpkrxrpv

Conversation

@lerebear

@lerebear lerebear commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Summary

In anticipation of "find references" for pytest fixtures, which enumerates possible fixture requests across every parameter of a function, this PR factors the shared, function-level work in fixture_request_for_parameter into FixtureRequestContext.

This lets the follow-up construct one context per function and reuse it for each candidate parameter, rather than repeatedly calling:

  • fixture_declaration, is_collected_test, and is_unittest_test_case to determine whether the function can request fixtures.
  • infer_definition_types to retrieve the function type.
  • mock_patch_count to determine how many parameters are supplied by unittest.mock.patch.

The existing fixture_request_for_parameter entry point now constructs a context and delegates to it, preserving behavior for existing callers. This is a behavior-preserving refactor.

Test Plan

This is a refactor that relies on existing test coverage (although I have backfilled a new test for some pre-existing behaviour).

@lerebear lerebear added the internal An internal refactor or improvement label Aug 26, 2026
@astral-sh-bot astral-sh-bot Bot added the ty Multi-file analysis & type inference label Aug 26, 2026
Base automatically changed from lerebear/push-xvsnymowqvzk to main August 26, 2026 18:13
@lerebear
lerebear force-pushed the lerebear/push-okknqpkrxrpv branch from e2d2206 to 191b17f Compare August 26, 2026 19:32
@astral-sh-bot

astral-sh-bot Bot commented Aug 26, 2026

Copy link
Copy Markdown

Typing conformance results

No changes detected ✅

Current numbers
The percentage of diagnostics emitted that were expected errors held steady at 97.79%. The percentage of expected errors that received a diagnostic held steady at 94.33%. The number of fully passing files held steady at 112/136.

@astral-sh-bot

astral-sh-bot Bot commented Aug 26, 2026

Copy link
Copy Markdown

Memory usage report

Memory usage unchanged ✅

@lerebear lerebear changed the title [ty] Refactor pytest fixture request classification [ty] Factor function-level work out of pytest fixture request lookup Aug 26, 2026
@astral-sh-bot

astral-sh-bot Bot commented Aug 26, 2026

Copy link
Copy Markdown

ecosystem-analyzer results

No diagnostic changes detected ✅

Full report with detailed diff (timing results)

@lerebear
lerebear marked this pull request as ready for review August 26, 2026 21:37
@lerebear
lerebear requested a review from a team as a code owner August 26, 2026 21:37
@astral-sh-bot
astral-sh-bot Bot requested a review from charliermarsh August 26, 2026 21:37
@lerebear
lerebear merged commit ceb9d31 into main Aug 26, 2026
67 checks passed
@lerebear
lerebear deleted the lerebear/push-okknqpkrxrpv branch August 26, 2026 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal An internal refactor or improvement ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant