diff --git a/src/darker/tests/helpers.py b/src/darker/tests/helpers.py index fffcf8cb1..dd4f950b7 100644 --- a/src/darker/tests/helpers.py +++ b/src/darker/tests/helpers.py @@ -1,13 +1,19 @@ """Helper functions for unit tests""" +from __future__ import annotations + import sys from contextlib import contextmanager from types import ModuleType -from typing import Generator, Optional +from typing import TYPE_CHECKING, Generator, Optional from unittest.mock import patch from darkgraylib.testtools.git_repo_plugin import GitRepoFixture +if TYPE_CHECKING: + import pytest + from _pytest.fixtures import SubRequest + @contextmanager def _package_present( @@ -55,7 +61,9 @@ def flynt_present(present: bool) -> Generator[None, None, None]: @contextmanager -def unix_and_windows_newline_repos(request, tmp_path_factory): +def unix_and_windows_newline_repos( + request: SubRequest, tmp_path_factory: pytest.TempPathFactory +) -> Generator[dict[str, GitRepoFixture], None, None]: """Create temporary repositories for Unix and windows newlines separately.""" with GitRepoFixture.context( request, tmp_path_factory diff --git a/src/darker/tests/test_git.py b/src/darker/tests/test_git.py index a3e2f0bb3..4c8a69d84 100644 --- a/src/darker/tests/test_git.py +++ b/src/darker/tests/test_git.py @@ -8,9 +8,11 @@ from subprocess import DEVNULL, check_call # nosec from textwrap import dedent # nosec from types import SimpleNamespace +from typing import Generator from unittest.mock import ANY, patch import pytest +from _pytest.fixtures import SubRequest from darker import git from darkgraylib.git import WORKTREE, RevisionRange @@ -321,7 +323,9 @@ def test_git_get_modified_python_files( @pytest.fixture(scope="module") -def git_get_modified_python_files_revision_range_repo(request, tmp_path_factory): +def git_get_modified_python_files_revision_range_repo( + request: SubRequest, tmp_path_factory: pytest.TempPathFactory +) -> Generator[GitRepoFixture]: """Fixture for a Git repository with multiple commits and branches.""" yield from branched_repo(request, tmp_path_factory)