Skip to content

fix: correct return type annotation for dbt_runner_freshness_success fixture#20903

Open
giulio-leone wants to merge 1 commit intoPrefectHQ:mainfrom
giulio-leone:fix/issue-20732-fixture-return-type
Open

fix: correct return type annotation for dbt_runner_freshness_success fixture#20903
giulio-leone wants to merge 1 commit intoPrefectHQ:mainfrom
giulio-leone:fix/issue-20732-fixture-return-type

Conversation

@giulio-leone
Copy link
Contributor

Summary

Fixes #20732

The dbt_runner_freshness_success pytest fixture in test_commands.py returns a MagicMock instance but was annotated as -> None. This causes static type checkers (pyrefly, mypy, pyright) to flag:

  1. The return _mock_dbt_runner_freshness_success statement as returning a value from a None-typed function
  2. Any downstream usage such as dbt_runner_freshness_success.assert_called_with(...) as calling a method on None

Change

  • Changed return annotation from -> None to -> MagicMock on the dbt_runner_freshness_success fixture (line 259)

Verification

  • MagicMock is already imported at the top of the file (from unittest.mock import MagicMock)
  • Other fixtures that only monkeypatch without returning (dbt_runner_model_result, dbt_runner_ls_result, dbt_runner_freshness_error, dbt_runner_failed_result) correctly use -> None and are left unchanged
  • The fixture's return value is actively used in test_trigger_dbt_cli_command_cli_argument_list which calls .assert_called_with() on it

…fixture

The `dbt_runner_freshness_success` pytest fixture returns a `MagicMock`
but was annotated as `-> None`. This causes type checkers (pyrefly, mypy) to
flag the return statement and any downstream usage such as
`dbt_runner_freshness_success.assert_called_with(...)` as a type error.

Change the return annotation from `None` to `MagicMock` to match the
actual return value.

Fixes PrefectHQ#20732

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 1, 2026 05:52
@github-actions github-actions bot added bug Something isn't working labels Mar 1, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a type annotation mismatch in the Prefect dbt CLI test suite so static type checkers correctly understand what the dbt_runner_freshness_success pytest fixture returns.

Changes:

  • Update dbt_runner_freshness_success fixture return annotation from None to MagicMock.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

type annotation has some error

2 participants